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

Already on GitHub? Sign in to your account

add support for slim templates #18

Closed
wants to merge 2 commits into
from

Conversation

Projects
None yet
4 participants

Saicheg commented Feb 6, 2014

Now we can use special 'ast'which means 'angular slim template' to handle slim templates.

@dmathieu dmathieu commented on an outdated diff Feb 6, 2014

lib/angular-rails-templates/version.rb
@@ -1,3 +1,3 @@
module AngularRailsTemplates
- VERSION = '0.0.4'
+ VERSION = '0.0.5'
@dmathieu

dmathieu Feb 6, 2014

Contributor

Please don't upgrade the gem version with your PR.
It's part of the gem releasing process, not of the feature.

@dmathieu dmathieu commented on the diff Feb 6, 2014

test/precompile_test.rb
@@ -11,6 +11,7 @@ def teardown
end
def delete_assets!
+ FileUtils.rm_rf app_path.join('tmp', 'cache')
@dmathieu

dmathieu Feb 6, 2014

Contributor

Is that really necessary? Couldn't the cache just be gitignored?
Also, if it is indeed necessary, the method name should be changed, since it's not only deleting assets anymore.

@Saicheg

Saicheg Feb 6, 2014

i want to clear cache here because we testing it in 3 different environments and we want to be sure that each test is isolated!

@dmathieu dmathieu commented on the diff Feb 6, 2014

lib/angular-rails-templates/template.rb
@@ -1,3 +1,4 @@
+require 'slim'
@dmathieu

dmathieu Feb 6, 2014

Contributor

Since slim isn't in the gemspec, if the user didn't specify it as an explicit dependncy, we won't be able to require it here.
Don't include slim in the gemspec of course. We should ignore require errors when slim isn't a dependency.

@dmathieu dmathieu commented on the diff Feb 6, 2014

lib/angular-rails-templates/template.rb
}]);
EOS
end
private
+
+ def content
+ case File.extname(file)
+ when /ast/ then Slim::Template.new(file).render
@dmathieu

dmathieu Feb 6, 2014

Contributor

If slim isn't specified as a dependency, we should provide a meaningful message here.

Contributor

dmathieu commented Feb 6, 2014

Thank you for your work here! 💙.
I've posted a few comments. Also, I think we should mention it in the README.
And if you could specify this new feature in the CHANGELOG (in the "unreleased" section), that'd be awesome.

Saicheg commented Feb 6, 2014

ok @dmathieu, will work on your comments in the evening! thank you too for an awesome gem!

Owner

pitr commented Feb 6, 2014

This is completely unnecessary. Rails/slim-rails already handles this just fine. Just use my_template.html.slim. Or my_template.html.haml, etc. We've been using my_template.html.erb and it works just fine.

Saicheg commented Feb 6, 2014

@pitr it depends on what you want. it does not preload them to $templateCache, right?

Contributor

dmathieu commented Feb 6, 2014

Actually, @pitr would be right.
Setting a file with name template.html.slim will first go through the slim engine; then through this gem's engine.

@dmathieu dmathieu closed this Feb 6, 2014

Saicheg commented Feb 6, 2014

really?
@dmathieu i am not able to run this gem under my current rails 4 project. It just do nothing. Wondering if you will help me to get it work right.

Contributor

dmathieu commented Feb 6, 2014

Could you send a sample app as simple as possible reproducing the issue?

Saicheg commented Feb 6, 2014

sure, i will create a repo and paste you a link!

Owner

pitr commented Feb 6, 2014

thanks @saicheg

Saicheg commented Feb 7, 2014

Ok @dmathieu @pitr, i create a new simple project and i am seeing a problem. It is still not the same problem i've got on my real project, my trying to compile all views gives me next code:

console.log('i am script');
(function() {
  console.log('i am coffee');

}).call(this);

window.AngularRailsTemplates || (window.AngularRailsTemplates = angular.module("templates", []));

window.AngularRailsTemplates.run(["$templateCache",function($templateCache) {
  $templateCache.put("views/sample.html", "\u003Ch1\u003EI am sample html view\u003C/h1\u003E\n");
}]);

window.AngularRailsTemplates || (window.AngularRailsTemplates = angular.module("templates", []));

window.AngularRailsTemplates.run(["$templateCache",function($templateCache) {
  $templateCache.put("views/slim_view.slim.html", "h1 I am sample slim view\n");
}]);

you can notice that slim compiled wrong, it should be:

window.AngularRailsTemplates.run(["$templateCache",function($templateCache) {
  $templateCache.put("views/slim_view.html.slim", "<h1>am sample slim view</h1>\n");
}]);

Here is a link: https://github.com/Saicheg/angular-rails-templates-sample

Saicheg commented Feb 8, 2014

@dmathieu @pitr have you a chance to loot at my sample project?

Owner

pitr commented Feb 8, 2014

I took a look, couldn't figure it out. Tried using slim-rails instead of slim.

Can you try haml and see if that works?

Saicheg commented Feb 9, 2014

hey @pitr, i tried slim-rails and haml-rails but still have no luck with it. check it out my last commit here:

Saicheg/angular-rails-templates-sample@5692713

Saicheg commented Feb 9, 2014

tried to do the same for rails 3 application, get same result

Saicheg commented Feb 9, 2014

i spend some time reading slim-rails, slim, haml-rails, haml and sprockets gems and realized that haml does not provide any interface for sprockets. They have their interfaces for rails action_view and that's it.

exviva commented Feb 9, 2014

@saicheg don't you need to do something like Rails.application.assets.register_engine('.slim', Slim::Template)?

Saicheg commented Feb 9, 2014

@exviva i tried, but it still doesn't work for me. Not sure what happens, but i got a feeling that sprockets just ignore all files with slim extenstion

Contributor

dmathieu commented Feb 10, 2014

I see you're using the gem from rubygems.
I just released 0.0.5 (there were bugfixes in the repository, which were not released). Can you try upgrading the gem and testing again?

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