templates.js 0.2.x changes
1. Namespace Assumption - deprecated
Previously within a loop you had a choice of doing {myarray.myprop}
or just {myprop}
. The latter has been deprecated:
myarray: [
{
myprop: myval
}
]
<!-- BEGIN myarray -->
{myarray.myprop}
{myprop} // this will now only reference myprop from the root, and no longer work for myarray.myprop
<!-- END myarray -->
That said, you can use {../myprop}
which will reference the current namespace. This is useful when you re-use partials in multiple templates. For example:
// partials/mypartial.tpl
{../myproperty}
<!-- BEGIN loop1 -->
<!-- IMPORT partials/mypartial.tpl --> // {loop1.myproperty}
<!-- END loop1 -->
<!-- BEGIN loop2 -->
<!-- IMPORT partials/mypartial.tpl --> // {loop2.myproperty}
<!-- END loop2 -->
2. All keys are now escaped by default
If you happen to include JavaScript in your template, (ex. {code}
) please use {{code}}
instead to ensure your JS isn't escaped.