slim.js icon indicating copy to clipboard operation
slim.js copied to clipboard

Idea for cleaner templates

Open jellehak opened this issue 4 years ago • 1 comments

In the templates this is required, perhaps a cleaner solution is to remove the this from your templates. This could been done for example by updating the expressionToJS function. See below:

  return '`' + str.replaceAll('{{', '${this.').replaceAll('}}', '}') + '`'

Result

Before

<h1>Hello, {{this.who}}!</h1>

After

<h1>Hello, {{who}}!</h1>

jellehak avatar Sep 17 '21 09:09 jellehak

Hi @jellehak, Can you please explain what is the pain point of using "this" in the template? The strict keyword this followed by a comma makes the detection very easy.

eavichay avatar Sep 26 '21 06:09 eavichay