squirrellyjs / squirrelly

Semi-embedded JS template engine that supports helpers, filters, partials, and template inheritance. 4KB minzipped, written in TypeScript ⛺
https://squirrelly.js.org
MIT License
599 stars 82 forks source link

undefined ... #104

Closed Indribell closed 5 years ago

Indribell commented 5 years ago

When having a tag in the code:

let myTemplate = `This is a template
My favorite template engine is: {{fav}}
My favorite kind of cake is: {{cake}}
Not used {{cakerrrsr}}
`;
 let templateResult = Sqrl.Render(myTemplate, {
        fav: "Squirrelly", cake: "Chocolate",
    });
This is a template
My favorite template engine is: Squirrelly
My favorite kind of cake is: Chocolate
Not used undefined

The "cakerrrsr" that has no matching data in a json, results in "undefined" being printed onscreen. It may be better to not display anything, like Handlebars and co do.

nebrelbug commented 5 years ago

That would be nice, but I think it might be better to keep it there so that users realize their value is undefined rather than Squirrelly hiding it from them.

nebrelbug commented 5 years ago

Hi @Indribell! I've been thinking about this, and I think that including an option to enable this behavior might be a nice feature for version 8! If you would like to see this, please comment on the version 8 issue I created.

Thanks!

ilanl commented 2 years ago

love to see this