angular-rails-templates: Templates not getting wrapped in expected javascript
The following problem is definitely not a problem with the gem as we have this running correctly on our staging and other development servers. Please feel free to close it immediately if you don’t have any ideas as to what it may be as it’s definitely an issue with my development machine. On the off-chance that you do though I wanted to just float it.
For some reason, on my local machine, rails-templates is not wrapping the normal javascript around the templates themselves. Instead of compiling into something like:
// Angular Rails Template
// source: app/assets/javascripts/copyin/directives/fast_reply/fast_reply_template.html.haml
angular.module("templates").run(["$templateCache", function($templateCache) {
$templateCache.put("copyin/directives/fast_reply/fast_reply_template.html", "<a class='{{fastReplyType}}' data-original-title='{{actionTooltip}}' href='' ng-class='{active: fastReplyIdForCurrentUser}' ng-click='toggleAction()' tooltip='tooltip'>\n {{actionName}}\n <span ng-if='fastReplyUsersFullNames.length > 0'>\n ({{fastReplyUsersFullNames.length}})\n </span>\n</a>")
}]);
The templates are simply compiling to:
<a class='{{fastReplyType}}' data-original-title='{{actionTooltip}}' href='' ng-class='{active: fastReplyIdForCurrentUser}' ng-click='toggleAction()' tooltip='tooltip'>
{{actionName}}
<span ng-if='fastReplyUsersFullNames.length > 0'>
({{fastReplyUsersFullNames.length}})
</span>
</a>
;
Have you ever seen this before? Do you have any immediately have any thoughts as to what config setting could be causing this? If not don’t sweat it but I thought it was worth asking
Thank you.
About this issue
- Original URL
- State: open
- Created 8 years ago
- Reactions: 1
- Comments: 19 (3 by maintainers)
I found my issue as well. We were using
Rails.root.jointo declare our sub directories, it appears v1.0.0 doesn’t respect absolute paths.Per @DarkArc’s comment, I looked into the sub directories. I was able to get it working properly after using the
inside_pathsconfig. We currently have our frontend in a separate folder fromapp. It used to work without the inside_paths config on0.1.3but seems to be required now on1.0.0. Not sure if that’s a bug or intended… but this got it to work.Ok so I managed to fix this but ended up finding two different ways that actually addressed it.
1. On some versions add the
inside_pathsoptionI keep a blank rails project to try these things out independently of everything in our application. This was running a very slightly different combo of
angular-templatesandsprocketsGem versions in my blank project
With this combination,
inside_pathsfixed it immediatelyAdding
config.angular_templates.inside_paths = ['app/assets']toapplication.rbimmediately fixed the issue and the templates came out sweetly.2. On older versions of angular-rails-templates you just need to upgrade…
Gem versions in our production project
With this combination, adding the config option
config.angular_templates.inside_paths = ['app/assets']did not unfortunately fix the problem.However upgrading to
Did fix it. Success.
Learnings from my experiments
See how up-to-date you can get. If you can’t get completely up-to-date then try adding the config option in