Template strings as a template language.

Isiah Meadows isiahmeadows at gmail.com
Sun Sep 13 23:14:53 UTC 2015


On Sun, Sep 13, 2015 at 7:09 PM, Mark S. Miller <erights at google.com> wrote:
>
>
> On Sun, Sep 13, 2015 at 8:58 AM, Bob Myers <rtm at gol.com> wrote:
>>
>> Templating languages typically "compile" templates into functions through
>> various lexical transformations.
>>
>> Consider a template file foo.tem:
>>
>> ```
>> My name is ${this.name}.
>> ```
>>
>> Lexically transform this into
>>
>> ```
>> function foo() {
>>   return `My name is ${this.name|}.`;
>> }
>>
>> Then invoke the template as eg
>>
>> ```
>> foo.call({name: 'Bob'})
>> ```
>>
>> Having said that, I doubt if ES6 template strings serve as a useful basis
>> for a full-fledged templating system. To take just one basic example, how
>> would one implement the equivalent of `{{#if}}`?
>
>
> What does `{{#if}}` mean?
>

An example from Handlebars' website (which is likely where he drew the
syntax from):

```
{{permalink}}
{{#each comments}}
  {{../permalink}}

  {{#if title}}
    {{../permalink}}
  {{/if}}
{{/each}}
```



>>
>>
>> Bob
>>
>>
>> _______________________________________________
>> es-discuss mailing list
>> es-discuss at mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
>>
>
>
>
> --
>     Cheers,
>     --MarkM
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>



-- 
Isiah Meadows


More information about the es-discuss mailing list