-
Notifications
You must be signed in to change notification settings - Fork 422
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
can.sub with strict properties mode #349
Comments
That's not how much templating systems work. For example: |
@justinbmeyer The idea came from my last project. Feature i need most is to keep result even there are missing values ( And in one case i found very useful what I called meta-templates. In one place i prerender template with few values and then reuse this meta-template. I know that i can achieve same result with keeping object and extend it with new values, but this seem more straightforward for me. First time, when i tried to use can.sub and i get |
@justinbmeyer Any suggestions? I worked on it little more and found, that variant with Without this feature do you think the strict mode is fine? can.sub("a:{a}", {}) // -> null
// with keepResult
can.sub("a:{a}", {}, false, true) // -> "a:" |
@schovi Thanks for submitting this issue. However, I don't think it's something most people need, and its not something the framework needs. can.sub is just a means to an end. Hopefully you can get this in lodash or some other micro-templating library. Thanks! |
Now when any of values is missing the
can.sub
returnsnull
I understand to needs of this in can.control and templated bindings.
I came with idea, how to improve
can.sub
as templating system.And I call it
strict mode
and can be controlled with fourth param in can.sub functionWhen
true
is passed it returnsnull
when any value is missing.When
false
is passed it returns new template where missing values are kept as template (meta-template).There is example of usage
strict
param:There is initial implementation https://github.com/schovi/canjs/compare/can-sub-strict
The text was updated successfully, but these errors were encountered: