New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Templates not being found #152

Open
jwarzech opened this Issue Mar 16, 2016 · 22 comments

Comments

Projects
None yet
@jwarzech

I just created a new rails 4.2 app and my templates are getting loaded int JST. I see in the issues that it looks like there was some version incompatibilities but as I understand @emilioforrer seems to have fixed these?

@rpbaltazar

This comment has been minimized.

Show comment
Hide comment
@rpbaltazar

rpbaltazar Mar 22, 2016

Is your JST being populated at all?
If I use the latest version of the gem 1.16.2 JST doesn't even get defined to me.

Is your JST being populated at all?
If I use the latest version of the gem 1.16.2 JST doesn't even get defined to me.

@jwarzech

This comment has been minimized.

Show comment
Hide comment
@jwarzech

jwarzech Mar 23, 2016

It will if I place a normal ".jst" file in my templates directory - I don't believe JST gets defined unless there is a single template it recognizes in the directory.

Since I can't get ".jst.hamlc" files to get recognized that object won't get defined if that is all I have in /templates

It will if I place a normal ".jst" file in my templates directory - I don't believe JST gets defined unless there is a single template it recognizes in the directory.

Since I can't get ".jst.hamlc" files to get recognized that object won't get defined if that is all I have in /templates

@rpbaltazar

This comment has been minimized.

Show comment
Hide comment
@rpbaltazar

rpbaltazar Mar 23, 2016

I believe that is in fact a bug.

I have a project that is using haml_coffee_assets 1.16.0 and hamlc files get loaded and JST gets defined.
The only problem is that the old version of the gem requires an old version of sprokets.

I'm open for suggestions here....

I believe that is in fact a bug.

I have a project that is using haml_coffee_assets 1.16.0 and hamlc files get loaded and JST gets defined.
The only problem is that the old version of the gem requires an old version of sprokets.

I'm open for suggestions here....

@derSascha

This comment has been minimized.

Show comment
Hide comment
@derSascha

derSascha Mar 24, 2016

Contributor

Looks like its a bug with sprockets-rails > 3.

This Gemfile works fine (server and client side hamlc rendering):

gem 'rails', '4.2.6'
gem 'sass-rails'
gem 'coffee-rails'
gem 'sprockets-rails', '< 3' # = 2.3.3
gem 'haml-rails'
gem 'haml_coffee_assets', '1.16.2'
gem 'jquery-rails'

After upgrading sprockets-rails, server side rendering works but templates are not available in assets pipepline anymore:

gem 'rails', '4.2.6'
gem 'sass-rails'
gem 'coffee-rails'
gem 'sprockets-rails', '> 3' # = 3.0.4
gem 'haml-rails'
gem 'haml_coffee_assets', '1.16.2'
gem 'jquery-rails'

Both versions are using sprockets 3.5.2. Any suggestions what changes in sprockets-rails?

Contributor

derSascha commented Mar 24, 2016

Looks like its a bug with sprockets-rails > 3.

This Gemfile works fine (server and client side hamlc rendering):

gem 'rails', '4.2.6'
gem 'sass-rails'
gem 'coffee-rails'
gem 'sprockets-rails', '< 3' # = 2.3.3
gem 'haml-rails'
gem 'haml_coffee_assets', '1.16.2'
gem 'jquery-rails'

After upgrading sprockets-rails, server side rendering works but templates are not available in assets pipepline anymore:

gem 'rails', '4.2.6'
gem 'sass-rails'
gem 'coffee-rails'
gem 'sprockets-rails', '> 3' # = 3.0.4
gem 'haml-rails'
gem 'haml_coffee_assets', '1.16.2'
gem 'jquery-rails'

Both versions are using sprockets 3.5.2. Any suggestions what changes in sprockets-rails?

@TheKidCoder

This comment has been minimized.

Show comment
Hide comment
@TheKidCoder

TheKidCoder Mar 25, 2016

Collaborator

I took a dive into the changes to sprockets that could cause this...
Unfortunately the changes are large and not well documented. Would be great to get someone more familiar with sprockets and the 3.x changes to take a look.

EDIT:
It looks like I didn't see a pull request that is pending. Need that merged in to fix this issue.
In the mean time, you can use this: https://github.com/TheKidCoder/haml_coffee_assets

Collaborator

TheKidCoder commented Mar 25, 2016

I took a dive into the changes to sprockets that could cause this...
Unfortunately the changes are large and not well documented. Would be great to get someone more familiar with sprockets and the 3.x changes to take a look.

EDIT:
It looks like I didn't see a pull request that is pending. Need that merged in to fix this issue.
In the mean time, you can use this: https://github.com/TheKidCoder/haml_coffee_assets

@arjun-urs

This comment has been minimized.

Show comment
Hide comment
@arjun-urs

arjun-urs Apr 27, 2016

+1. I am facing the same problem after upgrading the sprockets

@TheKidCoder Your fork did not fix the issue. Have you merged it yet?

arjun-urs commented Apr 27, 2016

+1. I am facing the same problem after upgrading the sprockets

@TheKidCoder Your fork did not fix the issue. Have you merged it yet?

@TheKidCoder

This comment has been minimized.

Show comment
Hide comment
@TheKidCoder

TheKidCoder May 3, 2016

Collaborator

Can you post your Gemfile.lock ? My branch is working for me (for the most part)...

Collaborator

TheKidCoder commented May 3, 2016

Can you post your Gemfile.lock ? My branch is working for me (for the most part)...

@arjun-urs

This comment has been minimized.

Show comment
Hide comment
@arjun-urs

arjun-urs May 6, 2016

@TheKidCoder Here is the Gemfile.lock gist. Please have a look.

https://gist.github.com/arjun-urs/d95bb094e0e37edfa299f5f4675ad663

Also, I am concerned with this repo, it's not up-to-date and many pull requests pending. I am wary of including this gem in future projects.

@TheKidCoder Here is the Gemfile.lock gist. Please have a look.

https://gist.github.com/arjun-urs/d95bb094e0e37edfa299f5f4675ad663

Also, I am concerned with this repo, it's not up-to-date and many pull requests pending. I am wary of including this gem in future projects.

@emilioforrer

This comment has been minimized.

Show comment
Hide comment
@emilioforrer

emilioforrer May 9, 2016

Owner

I just found this bug in a new project, where JST is undefined. I seems to be an incompatibility with sprockets-rails v3+.

As a work around you, can downgrade sprockets-rails to gem "sprockets-rails", "2.3.3" until this bug gets fixed

Owner

emilioforrer commented May 9, 2016

I just found this bug in a new project, where JST is undefined. I seems to be an incompatibility with sprockets-rails v3+.

As a work around you, can downgrade sprockets-rails to gem "sprockets-rails", "2.3.3" until this bug gets fixed

@TheKidCoder

This comment has been minimized.

Show comment
Hide comment
@TheKidCoder

TheKidCoder May 12, 2016

Collaborator

@arjun-urs I'm working on the upgrade for sprockets 3.x. In the mean time, @emilioforrer is right, you need to downgrade.

Collaborator

TheKidCoder commented May 12, 2016

@arjun-urs I'm working on the upgrade for sprockets 3.x. In the mean time, @emilioforrer is right, you need to downgrade.

@mmatviyiv

This comment has been minimized.

Show comment
Hide comment
@mmatviyiv

mmatviyiv Jun 9, 2016

The same issue guys
P.S: rails 4.2.6, haml_coffee_assets 1.16.2

mmatviyiv commented Jun 9, 2016

The same issue guys
P.S: rails 4.2.6, haml_coffee_assets 1.16.2

@mnoack

This comment has been minimized.

Show comment
Hide comment
@mnoack

mnoack Sep 8, 2016

@emilioforrer I think some people have solved it in their forks.
In rails 5 with sprockets 2 I get this deprecation:

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 in class:Engine at haml_coffee_assets-1.16.2/lib/haml_coffee_assets/rails/engine.rb:83)

This person's fork works for me (it doesn't resolve the deprecation, I note some other forks resolve the deprecation but didn't work for me) in rails 5 and sprockets 3
https://github.com/nolan/haml_coffee_assets/commits/master

With any luck perhaps adopting this change (or tweaking it) might just work.

mnoack commented Sep 8, 2016

@emilioforrer I think some people have solved it in their forks.
In rails 5 with sprockets 2 I get this deprecation:

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 in class:Engine at haml_coffee_assets-1.16.2/lib/haml_coffee_assets/rails/engine.rb:83)

This person's fork works for me (it doesn't resolve the deprecation, I note some other forks resolve the deprecation but didn't work for me) in rails 5 and sprockets 3
https://github.com/nolan/haml_coffee_assets/commits/master

With any luck perhaps adopting this change (or tweaking it) might just work.

@emilioforrer

This comment has been minimized.

Show comment
Hide comment
@emilioforrer

emilioforrer Sep 9, 2016

Owner

Thanks @mnoack.

Can you try the branch release/v2.0.0, to see if it works for you?

Owner

emilioforrer commented Sep 9, 2016

Thanks @mnoack.

Can you try the branch release/v2.0.0, to see if it works for you?

@mnoack

This comment has been minimized.

Show comment
Hide comment
@mnoack

mnoack Sep 9, 2016

@emilioforrer Yes that works. I will note before I had files in the format:
_blah.hamlc, _blah.jst.haml and blah.hamlc

I have to remove _ prefix and add '.jst' before hamlc before it worked, and that's probably a good thing because our files were so inconsistent!

mnoack commented Sep 9, 2016

@emilioforrer Yes that works. I will note before I had files in the format:
_blah.hamlc, _blah.jst.haml and blah.hamlc

I have to remove _ prefix and add '.jst' before hamlc before it worked, and that's probably a good thing because our files were so inconsistent!

@theoo

This comment has been minimized.

Show comment
Hide comment
@theoo

theoo Sep 11, 2016

@emilioforrer That works also for me with the following line in Gemfile:

gem 'haml_coffee_assets', github: "emilioforrer/haml_coffee_assets", branch: "release/v2.0.0"

and after renaming my files in *.jst.hamlc instead of just *.hamlc
It worked, but I had the following bug after the migration: #156, it's maybe related to the last change on the v2.0.0 branch.

theoo commented Sep 11, 2016

@emilioforrer That works also for me with the following line in Gemfile:

gem 'haml_coffee_assets', github: "emilioforrer/haml_coffee_assets", branch: "release/v2.0.0"

and after renaming my files in *.jst.hamlc instead of just *.hamlc
It worked, but I had the following bug after the migration: #156, it's maybe related to the last change on the v2.0.0 branch.

emilioforrer added a commit that referenced this issue Sep 16, 2016

Reverting commit 00ce444 for issue #152, going to fix deprecationn wa…
…rning later and create a sprocket 3+ extension
@frontandstart

This comment has been minimized.

Show comment
Hide comment
@frontandstart

frontandstart Sep 26, 2016

I just made little update - and get this, as new in backbone(have this on front) i can't realize what happens... so i use gem 'haml_coffee_assets' who depends on sprockets >= 2
may be dependency of this gem should set on sprockets < 3
upd.:
get generated templates but i think i have another problem it is - backbone js, i don't know it )

frontandstart commented Sep 26, 2016

I just made little update - and get this, as new in backbone(have this on front) i can't realize what happens... so i use gem 'haml_coffee_assets' who depends on sprockets >= 2
may be dependency of this gem should set on sprockets < 3
upd.:
get generated templates but i think i have another problem it is - backbone js, i don't know it )

@TheKidCoder

This comment has been minimized.

Show comment
Hide comment
@TheKidCoder

TheKidCoder Oct 26, 2016

Collaborator

I just released a new verion, 1.17.0, can you all give that a try and let me know if you are still having issues?

Collaborator

TheKidCoder commented Oct 26, 2016

I just released a new verion, 1.17.0, can you all give that a try and let me know if you are still having issues?

@theoo

This comment has been minimized.

Show comment
Hide comment
@theoo

theoo Oct 28, 2016

Hi @TheKidCoder, on my setup this unfortunately doesn't work. JST get populated but none of the array entries are functions that I could call with JST["path/to/my/view"]()

You can find a Gemfile.lock in the tree of my (work in progress) work.
This is how I load my views in Spine.js.

theoo commented Oct 28, 2016

Hi @TheKidCoder, on my setup this unfortunately doesn't work. JST get populated but none of the array entries are functions that I could call with JST["path/to/my/view"]()

You can find a Gemfile.lock in the tree of my (work in progress) work.
This is how I load my views in Spine.js.

@bikramwp

This comment has been minimized.

Show comment
Hide comment
@bikramwp

bikramwp Nov 4, 2016

Looking into this, I found that adding return to the following file fixes the issue:
https://github.com/emilioforrer/haml_coffee_assets/blob/master/lib/js/hamlcoffee.js#L790

So, template += "" + this.options.namespace + "['" + this.options.name + "'] = (context) -> ( ->\n"; to template += "" + "return " + this.options.namespace + "['" + this.options.name + "'] = (context) -> ( ->\n";

bikramwp commented Nov 4, 2016

Looking into this, I found that adding return to the following file fixes the issue:
https://github.com/emilioforrer/haml_coffee_assets/blob/master/lib/js/hamlcoffee.js#L790

So, template += "" + this.options.namespace + "['" + this.options.name + "'] = (context) -> ( ->\n"; to template += "" + "return " + this.options.namespace + "['" + this.options.name + "'] = (context) -> ( ->\n";

@ebeigarts

This comment has been minimized.

Show comment
Hide comment
@ebeigarts

ebeigarts Aug 29, 2017

I have managed to get this working by using HamlCoffeeAssets.config.placement = 'standalone' with Sprockets 3 and Rails 5.1.

Before:

(function() { this.JST || (this.JST = {}); this.JST["my_template"] = (function() {
    if (window.JST == null) {
      window.JST = {};
    }
  
    window.JST['my_template'] = function(context) {
      return (function() {
        var $c, $e, $o, title;
        $e = window.HAML.escape;
        $c = window.HAML.cleanValue;
        $o = [];
        $o.push("...");
        return $o.join("\n").replace(/\s([\w-]+)='“true'/mg, ' $1').replace(/\s([\w-]+)='“false'/mg, '').replace(/\s(?:id|class)=(['"])(\1)/mg, "");
      }).call(window.HAML.context(context));
    };
  
  }).call(this);;
}).call(this);

After (with standalone):

(function() { this.JST || (this.JST = {}); this.JST["my_template"] = (function() {
    return function(context) {
      return (function() {
        var $c, $e, $o, title;
        $e = window.HAML.escape;
        $c = window.HAML.cleanValue;
        $o = [];
        $o.push("...");
        return $o.join("\n").replace(/\s([\w-]+)='“true'/mg, ' $1').replace(/\s([\w-]+)='“false'/mg, '').replace(/\s(?:id|class)=(['"])(\1)/mg, "");
      }).call(context);
    };
  
  }).call(this);;
}).call(this);

I have managed to get this working by using HamlCoffeeAssets.config.placement = 'standalone' with Sprockets 3 and Rails 5.1.

Before:

(function() { this.JST || (this.JST = {}); this.JST["my_template"] = (function() {
    if (window.JST == null) {
      window.JST = {};
    }
  
    window.JST['my_template'] = function(context) {
      return (function() {
        var $c, $e, $o, title;
        $e = window.HAML.escape;
        $c = window.HAML.cleanValue;
        $o = [];
        $o.push("...");
        return $o.join("\n").replace(/\s([\w-]+)='“true'/mg, ' $1').replace(/\s([\w-]+)='“false'/mg, '').replace(/\s(?:id|class)=(['"])(\1)/mg, "");
      }).call(window.HAML.context(context));
    };
  
  }).call(this);;
}).call(this);

After (with standalone):

(function() { this.JST || (this.JST = {}); this.JST["my_template"] = (function() {
    return function(context) {
      return (function() {
        var $c, $e, $o, title;
        $e = window.HAML.escape;
        $c = window.HAML.cleanValue;
        $o = [];
        $o.push("...");
        return $o.join("\n").replace(/\s([\w-]+)='“true'/mg, ' $1').replace(/\s([\w-]+)='“false'/mg, '').replace(/\s(?:id|class)=(['"])(\1)/mg, "");
      }).call(context);
    };
  
  }).call(this);;
}).call(this);
@jcotillo

This comment has been minimized.

Show comment
Hide comment
@jcotillo

jcotillo Oct 9, 2017

Still experiencing this problem with v1.18.0 and rails 4.2. Are there plans to release a fix for this problem in the next version?

Using this fork github.com/nolan/haml_coffee_assets/ until further notice; since it also seems to support rails 5. Would prefer to use this gem directly though!

jcotillo commented Oct 9, 2017

Still experiencing this problem with v1.18.0 and rails 4.2. Are there plans to release a fix for this problem in the next version?

Using this fork github.com/nolan/haml_coffee_assets/ until further notice; since it also seems to support rails 5. Would prefer to use this gem directly though!

@covard

This comment has been minimized.

Show comment
Hide comment
@covard

covard Jan 4, 2018

@jcotillo you have it working with that fork? I am pointing to it and still having the depreciation warnings.

covard commented Jan 4, 2018

@jcotillo you have it working with that fork? I am pointing to it and still having the depreciation warnings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment