Skip to content
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

ft - component template engine helper for version 3.5.0 #2116

Open
jmvtrinidad opened this issue Aug 22, 2016 · 2 comments
Open

ft - component template engine helper for version 3.5.0 #2116

jmvtrinidad opened this issue Aug 22, 2016 · 2 comments
Milestone

Comments

@jmvtrinidad
Copy link

jmvtrinidad commented Aug 22, 2016

I recently using this feature on an expiremental durandal project and maybe someone find this helpful to knockoutjs.
In durandal, the function is inserted on viewEngine.js on line and the to convert all new bindings and the code became like this:

var newMarkup = templateEngineHelper(markup); //`markup` is the html node in string
var element = that.processMarkup(newMarkup);

This function will convert element attribute that has [] e.g. [text] or () e.g.(click) into html data-bind that will understand by knockout without changing behavior for existing data-bind.

New html binding with existing data-bind

<section>
    <h3>
        Features
        <!-- you can use it along data-bind -->
        <button data-bind="css:'btn btn-primary'" [text]="'Add Feature'" (click)="addFeature"></button>
    </h3>
    <ul [foreach]="features">
        <li [text]="$data"></li>
    </ul>
</section>

into

<section>
    <h3>
        Features
        <!-- you can use it along data-bind -->
        <button data-bind="css:'btn btn-primary',text:'Add Feature',event: { click:addFeature}" class="btn btn-primary">Add Feature</button>
    </h3>
    <ul data-bind="foreach: features">
        <li data-bind="text:$data"> </li>
    </ul>
</section>

You can find code here.

@brianmhunt
Copy link
Member

I like this. Are HTML attributes with [] and () a.) broadly supported? and b.) likely to break HTML validators?

Unfortunately the spec and practice diverge on custom attributes, so I have reservations about putting this mainline... but it might be a great plugin.

@jmvtrinidad
Copy link
Author

jmvtrinidad commented Oct 3, 2016

For a, It was all valid attribute name, but I'm not aware in browser
support. All attributes with () and [] will convert to normal
data-bind syntax so it will not render to DOM. And also for
bindingHandlers with camel case, it is not supported, an alternative is
to use normal data binding. I'm thinking to have an array of all camel case
bindingHandlers name and replace the value that it gets when getting
attributes with () and [].

For b, what do you mean by html validators?

On Mon, Oct 3, 2016, 8:48 PM Brian M Hunt notifications@github.com wrote:

I like this. Are HTML attributes with [] and () a.) broadly supported?
and b.) likely to break HTML validators?

Unfortunately the spec and practice diverge on custom attributes, so I
have reservations about putting this mainline... but it might be a great
plugin.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#2116 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AG3GvE-TCLz_tkaNT__AuW1bSI-oVeN0ks5qwPmegaJpZM4Jpkpm
.

@jmvtrinidad jmvtrinidad changed the title ft - template engine helper for version 3.5.0 ft - component template engine helper for version 3.5.0 Oct 4, 2016
@mbest mbest modified the milestone: Not assigned Dec 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants