envygeeks / jekyll-assets

:art: Asset pipelines for Jekyll.
ISC License
1.11k stars 169 forks source link

JST questions/problems #100

Closed phillipadsmith closed 10 years ago

phillipadsmith commented 10 years ago

I'm trying to experiment with JST compiling.

I've renamed my the HTML templates that I was loading previously loading with AJAX to .jst.

I've added a reference to the template in app.js with a //requires templatename

I now get an error: Uncaught SyntaxError: Unexpected token < at header.js (line 1)

Here's what's in header.js:

(function() { this.JST || (this.JST = {}); this.JST["header"] = <div class="navbar-fixed-top">
          <div class="container">
              <div class="row no-pad"></div>
          </div>
      </div>;
}).call(this);

Obviously, that doesn't look quite right.

Any clues on what to change to make this work?

Phillip.

ixti commented 10 years ago

You need to specify JST processor, e.g.: templatename.jst.ejs or templatename.jst.eco See details on sprockets' README on JST templating.

But generally, just renaming your file to name.jst.ejs will do the trick :D

phillipadsmith commented 10 years ago

Ah, okay, that wasn't / isn't clear in the README as I was not intending to use EJS or ECO, just plain old JavaScript / Underscore-style templates.

phillipadsmith commented 10 years ago

@ixti I renamed to .jst.ejs and required them in app.js and now I'm getting the following error. Thoughts?

➜  App git:(develop) ✗ bundle exec jekyll serve -w --config _config.yml
Configuration file: _config.yml
            Source: /Users/phillipadsmith/Development/name.org/App
       Destination: /Users/phillipadsmith/Development/name.org/App/_site
      Generating...
  Liquid Exception: cannot load such file -- ejs (in /Users/phillipadsmith/Development/name.org/App/ui/templates/about.jst.ejs) in _layouts/default.html
/Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/tilt-1.4.1/lib/tilt/template.rb:144:in `require': cannot load such file -- ejs (LoadError)
  (in /Users/phillipadsmith/Development/name.org/App/ui/templates/about.jst.ejs)
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/tilt-1.4.1/lib/tilt/template.rb:144:in `require_template_library'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/sprockets-2.12.1/lib/sprockets/ejs_template.rb:20:in `initialize_engine'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/tilt-1.4.1/lib/tilt/template.rb:56:in `initialize'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/sprockets-2.12.1/lib/sprockets/context.rb:196:in `new'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/sprockets-2.12.1/lib/sprockets/context.rb:196:in `block in evaluate'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/sprockets-2.12.1/lib/sprockets/context.rb:194:in `each'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/sprockets-2.12.1/lib/sprockets/context.rb:194:in `evaluate'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/sprockets-2.12.1/lib/sprockets/processed_asset.rb:12:in `initialize'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/sprockets-2.12.1/lib/sprockets/base.rb:374:in `new'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/sprockets-2.12.1/lib/sprockets/base.rb:374:in `block in build_asset'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/sprockets-2.12.1/lib/sprockets/base.rb:395:in `circular_call_protection'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/sprockets-2.12.1/lib/sprockets/base.rb:373:in `build_asset'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/sprockets-2.12.1/lib/sprockets/index.rb:94:in `block in build_asset'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/sprockets-2.12.1/lib/sprockets/caching.rb:58:in `cache_asset'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/sprockets-2.12.1/lib/sprockets/index.rb:93:in `build_asset'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/sprockets-2.12.1/lib/sprockets/base.rb:287:in `find_asset'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/sprockets-2.12.1/lib/sprockets/index.rb:61:in `find_asset'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/jekyll-assets-0.8.1/lib/jekyll/assets_plugin/patches/index_patch.rb:16:in `__wrap_find_asset'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/sprockets-2.12.1/lib/sprockets/processed_asset.rb:111:in `block in resolve_dependencies'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/sprockets-2.12.1/lib/sprockets/processed_asset.rb:105:in `each'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/sprockets-2.12.1/lib/sprockets/processed_asset.rb:105:in `resolve_dependencies'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/sprockets-2.12.1/lib/sprockets/processed_asset.rb:97:in `build_required_assets'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/sprockets-2.12.1/lib/sprockets/processed_asset.rb:16:in `initialize'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/sprockets-2.12.1/lib/sprockets/base.rb:374:in `new'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/sprockets-2.12.1/lib/sprockets/base.rb:374:in `block in build_asset'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/sprockets-2.12.1/lib/sprockets/base.rb:395:in `circular_call_protection'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/sprockets-2.12.1/lib/sprockets/base.rb:373:in `build_asset'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/sprockets-2.12.1/lib/sprockets/index.rb:94:in `block in build_asset'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/sprockets-2.12.1/lib/sprockets/caching.rb:58:in `cache_asset'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/sprockets-2.12.1/lib/sprockets/index.rb:93:in `build_asset'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/sprockets-2.12.1/lib/sprockets/base.rb:287:in `find_asset'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/sprockets-2.12.1/lib/sprockets/index.rb:61:in `find_asset'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/jekyll-assets-0.8.1/lib/jekyll/assets_plugin/patches/index_patch.rb:16:in `__wrap_find_asset'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/sprockets-2.12.1/lib/sprockets/bundled_asset.rb:16:in `initialize'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/sprockets-2.12.1/lib/sprockets/base.rb:377:in `new'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/sprockets-2.12.1/lib/sprockets/base.rb:377:in `build_asset'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/sprockets-2.12.1/lib/sprockets/index.rb:94:in `block in build_asset'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/sprockets-2.12.1/lib/sprockets/caching.rb:58:in `cache_asset'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/sprockets-2.12.1/lib/sprockets/index.rb:93:in `build_asset'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/sprockets-2.12.1/lib/sprockets/base.rb:287:in `find_asset'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/sprockets-2.12.1/lib/sprockets/index.rb:61:in `find_asset'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/jekyll-assets-0.8.1/lib/jekyll/assets_plugin/patches/index_patch.rb:16:in `__wrap_find_asset'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/sprockets-2.12.1/lib/sprockets/environment.rb:75:in `find_asset'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/jekyll-assets-0.8.1/lib/jekyll/assets_plugin/environment.rb:52:in `find_asset'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/sprockets-2.12.1/lib/sprockets/base.rb:295:in `[]'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/jekyll-assets-0.8.1/lib/jekyll/assets_plugin/renderer.rb:38:in `render_tag'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/jekyll-assets-0.8.1/lib/jekyll/assets_plugin/renderer.rb:23:in `render_javascript'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/jekyll-assets-0.8.1/lib/jekyll/assets_plugin/tag.rb:11:in `render'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/liquid-2.5.5/lib/liquid/block.rb:106:in `block in render_all'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/liquid-2.5.5/lib/liquid/block.rb:93:in `each'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/liquid-2.5.5/lib/liquid/block.rb:93:in `render_all'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/liquid-2.5.5/lib/liquid/block.rb:82:in `render'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/liquid-2.5.5/lib/liquid/template.rb:124:in `render'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/liquid-2.5.5/lib/liquid/template.rb:132:in `render!'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/jekyll-2.0.3/lib/jekyll/tags/include.rb:111:in `block in render'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/liquid-2.5.5/lib/liquid/context.rb:105:in `stack'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/jekyll-2.0.3/lib/jekyll/tags/include.rb:109:in `render'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/liquid-2.5.5/lib/liquid/block.rb:106:in `block in render_all'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/liquid-2.5.5/lib/liquid/block.rb:93:in `each'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/liquid-2.5.5/lib/liquid/block.rb:93:in `render_all'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/liquid-2.5.5/lib/liquid/block.rb:82:in `render'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/liquid-2.5.5/lib/liquid/template.rb:124:in `render'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/liquid-2.5.5/lib/liquid/template.rb:132:in `render!'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/jekyll-2.0.3/lib/jekyll/convertible.rb:96:in `render_liquid'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/jekyll-2.0.3/lib/jekyll/convertible.rb:142:in `render_all_layouts'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/jekyll-2.0.3/lib/jekyll/convertible.rb:176:in `do_layout'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/jekyll-2.0.3/lib/jekyll/post.rb:266:in `render'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/jekyll-2.0.3/lib/jekyll/site.rb:245:in `block in render'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/jekyll-2.0.3/lib/jekyll/site.rb:244:in `each'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/jekyll-2.0.3/lib/jekyll/site.rb:244:in `render'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/jekyll-2.0.3/lib/jekyll/site.rb:43:in `process'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/jekyll-2.0.3/lib/jekyll/command.rb:43:in `process_site'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/jekyll-2.0.3/lib/jekyll/commands/build.rb:46:in `build'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/jekyll-2.0.3/lib/jekyll/commands/build.rb:30:in `process'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/jekyll-2.0.3/lib/jekyll/commands/serve.rb:23:in `block (2 levels) in init_with_program'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/mercenary-0.3.3/lib/mercenary/command.rb:220:in `call'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/mercenary-0.3.3/lib/mercenary/command.rb:220:in `block in execute'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/mercenary-0.3.3/lib/mercenary/command.rb:220:in `each'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/mercenary-0.3.3/lib/mercenary/command.rb:220:in `execute'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/mercenary-0.3.3/lib/mercenary/program.rb:35:in `go'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/mercenary-0.3.3/lib/mercenary.rb:22:in `program'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/gems/jekyll-2.0.3/bin/jekyll:18:in `<top (required)>'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/bin/jekyll:23:in `load'
    from /Users/phillipadsmith/Development/name.org/App/_vendor/ruby/2.1.0/bin/jekyll:23:in `<main>`
phillipadsmith commented 10 years ago

Going to try to install the ejs gem...

phillipadsmith commented 10 years ago

Okay, that seems to solve the issue. I'll submit a doc patch that makes that all more obvious. :)

ixti commented 10 years ago

)) thanks On 17 Sep 2014 19:56, "Phillip Smith" notifications@github.com wrote:

Okay, that seems to solve the issue. I'll submit a doc patch that makes that all more obvious. :)

— Reply to this email directly or view it on GitHub https://github.com/ixti/jekyll-assets/issues/100#issuecomment-55933552.