#30 new
Alex Koppel

JST Processor doesn't escape code

Reported by Alex Koppel | July 7th, 2011 @ 02:21 PM


Thanks for the great gem. I may be using it wrong, but JST doesn't seem to work for me.

In a manifest, I included a jST file called trip_list.jst via:
    //= require views/trip_list

In the resulting js file, I get the following:
    this.JST["views/trip_list"] = <ul class="tripList"> // etc

Which of course gives me a browser error:
    home.bundle:32 Uncaught SyntaxError: Unexpected token <

It looks like the JST is not being properly formatted / inserted as a string inside the resulting JS file.

I've probably just missed a step somewhere, but would be happy to submit a pull request if this is a genuine bug. Any help would be appreciated.



Comments and changes to this ticket

  • Andrew

    Andrew August 11th, 2011 @ 01:15 PM

    • Assigned user set to “Sam Stephenson”
    • Tag set to invalid


    The JST processor simply takes the results from other template processes and places it in a JST lookup table.
    If you want the template escaped then it should be run through a different template process first.



        <p>Hello World</p>

    results in:

        this.JST['view'] = <p>Hello World</p>

    If you install the hamljs gem (which I just wrote because I had to just figure this out), then:


        %p Hello World

    results in:

        this.JST['view'] = HAML('%p Hello World')

    You can use other preprocessors such as ejs (gem by the same author as sprockets)

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

JavaScript dependency management and concatenation
<a href="http://getsprockets.org/">http://getsprockets.org/</a>

People watching this ticket