Ruby Like Notation #{ … } To Mix Strings And Variables

New feature for our JavaScript template engine PURE

From revision 1.7 on, there is a new shortcut available to concatenate strings.

We’ll take a similar HTML as our basic Hello World example:

<div>
    Hello <span>World</span>
</div>

Now we remove the “Hello ” string:

<div>
    <span>World</span>
</div>

Here is the JSON we’ll use to render this HTML:

var json = { "name": "Mary" }

And now the directive that will link them both:

var dir = { "span": "Hello #{name}"}

Direct assignation continues to work.

For more information and examples, visit the dedicated Wiki page

Stay tuned

One thought on “Ruby Like Notation #{ … } To Mix Strings And Variables

  1. Pingback: pozycjonowanie wroclaw