Git Product home page Git Product logo

mustache's People

Contributors

delgaylord avatar janbliznicenko avatar noha avatar thibaultar avatar yanndub avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

mustache's Issues

Where to add charset conversions

I would like to add character set conversion to mustache for my port on VA Smalltalk.

Background: VA Smalltalk doesn't natively speak UTF-8, so I'd like to convert all insertions into a template to UTF-8.

So I wonder what a good place for such an extension would be. My first impulse would be to add an inst var to MustacheTemplate, maybe named #charSet.
Then I think the next best thing to do would be to add a parameter to all implementors of #mustacheLookup: which is either nil or the charset to convert to.

The problem: a MustachePart doesn't know the MustacheTemplate, so there is no way of asking a template for the value of its charSet when it is trying to fill in text....

Any ideas?

Variables are not resolved in parent context

Variable should walk up the contexts in order to resolve a name:

Variables
The most basic tag type is the variable. A {{name}} tag in a basic template will try to find the name key in the current context. If there is no name key, the parent contexts will be checked recursively. If the top context is reached and the name key is still not found, nothing will be rendered.

Cannot use section value inside a section

Given this simple template:

template := MustacheTemplate on: '{{#items}}
  {{#first}}
    <li><strong>{{name}}</strong></li>
  {{/first}}
  {{#link}}
    <li><a href="{{link}}">{{name}}</a></li>
  {{/link}}
{{/items}}'.

I evaluate the template using this data:

template value: { 
  'items' -> { 
      {'name'-> 'red' . 'first' -> true . 'url' -> #Red } asDictionary .
      {'name' -> 'green' . 'link' -> 'https://pharo.org' . 'url' -> #Green } asDictionary
  } } asDictionary.

I would expect the following output:

<li><strong>red</strong></li>
<li><a href="https://pharo.org"></a></li>

but I get:

<li><strong>red</strong></li>
<li><a href=""></a></li>

If link is set to nil, the second list element will not be displayed (as expected). It looks like the section variable value is well handled but then impossible to use in the section

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.