Giter Site home page Giter Site logo

Comments (4)

leshill avatar leshill commented on August 22, 2024

Hi Luigi,

Does your application.js file require the templates file? If you have a file app/assets/templates/example.jst.hbs then you should see this in your generated application.js:

(function() {
  this.JST || (this.JST = {});
  this.JST["example"] = function(context) {
  ...

What does you Gemfile look like?

from handlebars_assets.

grigio avatar grigio commented on August 22, 2024

I changed in application.js

//= require_tree ../templates/notes

with

//= require ../templates/notes/show.jst.hbs

and now it works as expected, does require_tree work with templates and sub-folders?

from handlebars_assets.

leshill avatar leshill commented on August 22, 2024

Hi Luigi,

I just ran a sample app with rake assets:precompile and it works. One thing to note is that the JST variable is only available after the templates have been loaded. This means that if your application.js looks like this:

//= require jquery
//= require handlebars
//= require_tree .
//= require_tree ../templates

Then the js files included on line 3 cannot access JST until after line 4 has pulled in the templates, usually by deferring with jQuery's document ready, like so (this is a .coffee file):

$(->
  alert(JST['pages/one']())
)

Is handlebars_assets working for you now?

from handlebars_assets.

grigio avatar grigio commented on August 22, 2024

Yes it works. Thanks

from handlebars_assets.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.