Giter VIP home page Giter VIP logo

jquery-tmpl-rails's People

Contributors

jimmycuadra avatar stevenh512 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

jquery-tmpl-rails's Issues

Vendor asset no more included

Hi,

Since you removed inheritance from Rails::Engine, Rails doesn't known you're providing the asset "jquery-tmpl", and your gem doesn't appear in Rails.application.config.assets.paths anymore.
Could you fix this, please ?

couldn't find file 'jquery-tmpl' with type 'application/javascript'

I'm running

Rails 4.2.1
rake, version 10.4.2
Bundler version 1.10.5
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin14.0]

and I've added

//= require jquery-tmpl
//= require_tree ./templates

to my Gem (and the jquery-tmpl-rails gem to my Gemfile of cause) - but when I use the gem the page load stops with the above mentioned "couldn't find file" error - and a stack trace looking like this:

/Users/walther/Projects/gems/oxen_media/app/assets/javascripts/oxen_media.js:2
sprockets (3.2.0) lib/sprockets/resolve.rb:64:in `resolve!'
sprockets (3.2.0) lib/sprockets/directive_processor.rb:399:in `resolve'
sprockets (3.2.0) lib/sprockets/directive_processor.rb:207:in `process_require_directive'
sprockets (3.2.0) lib/sprockets/directive_processor.rb:180:in `block in process_directives'
sprockets (3.2.0) lib/sprockets/directive_processor.rb:178:in `each'
sprockets (3.2.0) lib/sprockets/directive_processor.rb:178:in `process_directives'
sprockets (3.2.0) lib/sprockets/directive_processor.rb:83:in `_call'
sprockets (3.2.0) lib/sprockets/directive_processor.rb:68:in `call'
sprockets (3.2.0) lib/sprockets/processor_utils.rb:75:in `call_processor'
sprockets (3.2.0) lib/sprockets/processor_utils.rb:57:in `block in call_processors'
sprockets (3.2.0) lib/sprockets/processor_utils.rb:56:in `reverse_each'
sprockets (3.2.0) lib/sprockets/processor_utils.rb:56:in `call_processors'
sprockets (3.2.0) lib/sprockets/loader.rb:86:in `load_asset_by_uri'
sprockets (3.2.0) lib/sprockets/loader.rb:45:in `block in load'
sprockets (3.2.0) lib/sprockets/loader.rb:155:in `fetch_asset_from_dependency_cache'
sprockets (3.2.0) lib/sprockets/loader.rb:38:in `load'
sprockets (3.2.0) lib/sprockets/cached_environment.rb:20:in `block in initialize'
sprockets (3.2.0) lib/sprockets/cached_environment.rb:47:in `yield'
sprockets (3.2.0) lib/sprockets/cached_environment.rb:47:in `load'
sprockets (3.2.0) lib/sprockets/bundle.rb:23:in `block in call'
sprockets (3.2.0) lib/sprockets/utils.rb:183:in `dfs'
sprockets (3.2.0) lib/sprockets/bundle.rb:24:in `call'
sprockets (3.2.0) lib/sprockets/processor_utils.rb:75:in `call_processor'
sprockets (3.2.0) lib/sprockets/processor_utils.rb:57:in `block in call_processors'
sprockets (3.2.0) lib/sprockets/processor_utils.rb:56:in `reverse_each'
sprockets (3.2.0) lib/sprockets/processor_utils.rb:56:in `call_processors'
sprockets (3.2.0) lib/sprockets/loader.rb:86:in `load_asset_by_uri'
sprockets (3.2.0) lib/sprockets/loader.rb:45:in `block in load'
sprockets (3.2.0) lib/sprockets/loader.rb:155:in `fetch_asset_from_dependency_cache'
sprockets (3.2.0) lib/sprockets/loader.rb:38:in `load'
sprockets (3.2.0) lib/sprockets/cached_environment.rb:20:in `block in initialize'
sprockets (3.2.0) lib/sprockets/cached_environment.rb:47:in `yield'
sprockets (3.2.0) lib/sprockets/cached_environment.rb:47:in `load'
sprockets (3.2.0) lib/sprockets/base.rb:63:in `find_asset'
sprockets (3.2.0) lib/sprockets/environment.rb:30:in `find_asset'
sprockets (3.2.0) lib/sprockets/base.rb:89:in `[]'
sprockets-rails (2.3.2) lib/sprockets/rails/helper.rb:230:in `lookup_asset_for_path'
sprockets-rails (2.3.2) lib/sprockets/rails/helper.rb:190:in `check_errors_for'
sprockets-rails (2.3.2) lib/sprockets/rails/helper.rb:137:in `block in javascript_include_tag'
sprockets-rails (2.3.2) lib/sprockets/rails/helper.rb:136:in `map'
sprockets-rails (2.3.2) lib/sprockets/rails/helper.rb:136:in `javascript_include_tag'
app/views/layouts/_head.html.haml:26:in `_app_views_layouts__head_html_haml___3569935750097020933_70308056945640'

might you have a clou on this?

cheers,
Walther

Improvement suggestion

Hi,

First, thanks a lot for your amazing job on that gem. I'm using it and it works (almost) like a charm. I just changed the naming of templates not to include folder name in the final name (to allow multiple styles switching) but for all other things its perfect.

I have a suggestion, though, that you may want to look at: I suggest you include helpers in the compilation process. Since templates are quite like views, I often need my helpers and I have to do things like
<% environment.context_class.instance_eval { include ApplicationHelper } %>
on top of every single template I create, which is ok for me but could be done in your gem, I suppose (and maybe with a way not to do it, like an option for instance).

Don't hesitate to challenge me on this.

Yann

Fixing jquery-tmpl-rails Sprockets deprecations

This is also filed under Sprockets core for guidance here.

Versions

  • Ruby 2.4.3
  • Rails 5.1.3
  • sprockets 3.7.3
  • jquery-tmpl-rails 1.1.0

Issue:

The latest version of jquery-tmpl-rails triggers a sprockets deprecation warning of:

    DEPRECATION WARNING: Sprockets method `register_engine` is deprecated.
    Please register a mime type using `register_mime_type` then
    use `register_compressor` or `register_transformer`.

    https://github.com/rails/sprockets/blob/master/guides/extending_sprockets.md#supporting-all-versions-of-sprockets-in-processors 
    (called from block (2 levels) in <class:Railtie> at /my/path/to/gems/jquery-tmpl-rails-ef6f58001d41/lib/jquery-tmpl-rails/engine.rb:10)

Attempts at resolution:

Following the deprecation warning, the problem within the gem simply resides here: https://github.com/jimmycuadra/jquery-tmpl-rails/blob/master/lib/jquery-tmpl-rails/engine.rb#L10

Which is currently:

app.assets.register_engine(".tmpl", JqueryTemplate)

I then visited the sprockets guide for handling deprecations, extensibility and compliance with sprockets 2,3,4. https://github.com/rails/sprockets/blob/master/guides/extending_sprockets.md#supporting-all-versions-of-sprockets-in-processors

I made my best attempt at rectifying the problem with a commit on this fork here: oceanshq@de7a598

Which was:

    asset.register_mime_type 'application/javascript', extensions: ['.tmpl'], charset: :unicode
    asset.register_preprocessor 'application/javascript', JqueryTemplate

However, this attempt simply deals out breakages when trying to run the web application at all or test it on the CI. So obviously I've missed something. I am not the gem maintainer but am trying to put this PR together myself as we rely on this gem.

Questions

  • Is there a simple syntactical approach I am missing here?
  • It was unclear to me in the docs, although register_engine is deprecated in Sprockets 3, is it actually possible to migrate from register_engine while staying in Sprockets 3?
  • If we are remaining on Sprockets 3 for the foreseeable future, is it kosher to silence this? Generally I work viewing deprecations as 'bugs that need fixing' and would rather not.

Sprockets can't find template file

Sprockets raises an error trying to require the file

application.js:1Uncaught Error: Sprockets::FileNotFound: couldn't find file 'tmpl/message'
(in /Users/recipher/code/mentor/app/assets/javascripts/application.js:30)

It raises the same error if the file is in the tmpl directory or in the root of javascripts.

If I put a leading / into the require:

/tmpl/message

The error does not get raised but when calling $.tmpl("tmpl/message", ...) the template is not used and the template filename is written out.

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.