Skip to content

Properties in Converters #157

blackmambahk opened this Issue Sep 6, 2012 · 2 comments

2 participants


Is here or your blog a better place to discuss JsRender features?

What I wanted to talk about was converters and tags -- particularly the lack of props on converters.

The 'for instance' on this is say a datetime converter.

This would currently be {{datetime:MyDateField}}
which is great but in this case there are several possible formats for the the date (as generally with other types of formatters), ideally I would like to do {{datetime:MyDateField, fmt="long"}} but converters don't have access to props, so the only alternative is to implement this as a tag {{datetime MyDateField fmt="long" /}} but to be honest, to me it just looks and feels wrong, and conceptually I think everyone tends to think of a formatter as a 'converter' rather than a tag which for the most part in JsRender are structural ie for/if-then-else etc etc...

Converters in my mind will often be parameterised, except in the simplest of cases.

I guess the issue maybe trying to figure using out using a regex where the props are given that the converter syntax currently supports almost any value expression.


Thanks for raising this, and yes, I hear you. Looking at providing access to props and args. (BTW Issues here, rather than my blog, is probably better for discussion. Sometimes I won't reply rapidly to issues, but I always get back to them if they are still open...)

@BorisMoore BorisMoore added a commit that referenced this issue Dec 3, 2012
@BorisMoore Commit counter 22. Major update, including some BREAKING CHANGES, and…
… many

new features. More samples and documentation for new features will be added
incrementally in coming updates.

Among the changes:

Detailed APIs modified for consistent arguments and use of this
pointer, and for maximum extensibility. See updated samples for usage...

Compiled templates restructured for easier debugging.

View object restructured for clarity.

View now has a type property, e.g. type="item"
Only "item" views have index properties, but to get the index from a nested
view use view.get("item").index.

nodes collection on a view is now a function, view.nodes().

Settings grouped onto a $.views.settings object.
View navigation features improved, with view.get(...) and $.view(elem, ...)
tagCtx object provides improved access to the args and properties of a tag

Adding resources (helpers, converters, tags, etc) to a template now supported
by passing parent template to API. e.g. $.tags({...}, parentTemplate).
Many improvements to custom tags, - used also as part of JsViews integration
for new JsViews Tag Controls. (Instantiation of tags as control instances).

Template inclusion now supported with simpler syntax {{for tmpl=.../))

Fixes for issues #169, #162, #157, #156, #155, #153, #145

This is now enabled in commit 22.

For example,, or this.tagCtx.args[2]

See sample

@BorisMoore BorisMoore closed this Dec 3, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.