Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

KnockoutJs and Templates - No code highlighting / completion in visual studio?

I have been playing with the tutorials on the knockout site and have enjoyed working with it.

So i decided to make a simple site with it. I was saddened to notice that i lose a lot of the support from the IDE when working with the javascript templates (highlighting, code completion)

Example template:

<script type="text/html" id="taskTemplate">
    <li>
        <input type="checkbox" data-bind="checked: isDone" />
        <input data-bind="value: title, enable: !isDone()" />
        <a href="#" data-bind="click: remove">Delete</a>
    </li>
</script>

Is this something you have to just swallow or is it avoidable / fixable? Templates seem to be one of the most used ways of building up the page and so i would prefer to have the support from the IDE.

like image 302
4imble Avatar asked Dec 07 '22 19:12

4imble


1 Answers

To get around this I create two html helpers for the begining of my script tag and the end of my script tag. Something like:

<% Html.BeginTemplate(new { id = "features-template" }); %>
    <li>
        <input type="checkbox" data-bind="checked: isDone" />
        <input data-bind="value: title, enable: !isDone()" />
        <a href="#" data-bind="click: remove">Delete</a>
    </li>
<% Html.EndTemplate(); %>
like image 142
Keith.Abramo Avatar answered Dec 10 '22 11:12

Keith.Abramo