pitr / angular-rails-templates Goto Github PK
View Code? Open in Web Editor NEWUse your angular templates with rails' asset pipeline
Home Page: https://rubygems.org/gems/angular-rails-templates
License: MIT License
Use your angular templates with rails' asset pipeline
Home Page: https://rubygems.org/gems/angular-rails-templates
License: MIT License
Hi,
I am having issues getting the gem to work with the karma testrunner, because it can't find the 'templates' module.
Are there any way in how I can include the Javascript from the 'templates' module in my configuration for Karma?
Error message:
Module 'templates' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
Must be related to 093e2dc
Since updating to the latest version of angular-rails-templates
(from whichever version was the last with .nghaml
😃), I get the following messages when running a rails
command:
WARN: tilt autoloading 'liquid' in a non thread-safe way; explicit require 'liquid' suggested.
WARN: tilt autoloading 'redcarpet' in a non thread-safe way; explicit require 'redcarpet' suggested.
WARN: tilt autoloading 'rdiscount' in a non thread-safe way; explicit require 'rdiscount' suggested.
WARN: tilt autoloading 'rdiscount' in a non thread-safe way; explicit require 'rdiscount' suggested.
WARN: tilt autoloading 'bluecloth' in a non thread-safe way; explicit require 'bluecloth' suggested.
WARN: tilt autoloading 'kramdown' in a non thread-safe way; explicit require 'kramdown' suggested.
WARN: tilt autoloading 'maruku' in a non thread-safe way; explicit require 'maruku' suggested.
WARN: tilt autoloading 'radius' in a non thread-safe way; explicit require 'radius' suggested.
WARN: tilt autoloading 'redcloth' in a non thread-safe way; explicit require 'redcloth' suggested.
WARN: tilt autoloading 'wikicloth' in a non thread-safe way; explicit require 'wikicloth' suggested.
WARN: tilt autoloading 'creole' in a non thread-safe way; explicit require 'creole' suggested.
This seems to interfere with the ability of spring to reload intelligently, as if I (say) edit config/application.rb
, then run another rails command, it just hangs until I run spring stop
and try again (which then displays those messages).
If I edit out the references to the markup types I don't use (line 12 of engine.rb
), I don't get the error messages, and spring's auto-reloading seems to work fine.
Not sure what to make of this since it's potentially both a tilt problem and a spring problem, but I figured I'd at least bring it up.
When I have a folder with lets say:
/directives/targeting.js
/directives/targeting.html
It seems that the template cache can't find the template, any ideas?
Hi,
I am using angular-ui-router, and I have one state at the moment for the home state.
config(['$stateProvider', function ($stateProvider) {
$stateProvider.state('home', {
url: '/',
views: {
"navigation": { templateUrl: 'navigation.html', controller: 'NavigationCtrl' },
"content": { templateUrl: 'home.html', controller: 'HomeCtrl' }
}
});
However, when I load the root application, I see this error on the rails server:
ActionController::RoutingError (No route matches [GET] "/home.html"):
I have the home.html.erb file under: app/assets/templates. I have also included the gem file and dependencies on the templates for the angular application. It appears to be downloading the templates as javascript files, but not loading them into the content view for the home state. It seems like it is trying to download the template from the templateUrl as it normally would without the plugin.
Hi.
I was trying to prepare the pull request for enabling support haml and slim templates. But I can't find out how to run the tests in the right way. Probably you help me to do it.
Thank you!
Hello!
I'm trying to use that gem but i'm not able to. Let's start from basics:
I'm adding gem 'angular-rails-templates'
, fireing bundle install
and restarting my app. After that, i'm adding //= require angularjs
to my application.js file. From that point, my rails app throws couldn't find file 'angularjs'
exception.
Originally, i was trying to enable that gem for my rails engine but output was the same so i've tried installing it on a regular rails app (the root one, not engine). When i'll handle that issue on a root app, i'm gonna try enabling it in engine but that's for later.
I'm on ruby 2.0.0 / rails 4.0.3
Thanks in advance!
In the dummy test-app, I commented out the require "sprockets/railtie"
assuming that that is what created app.config.assets
, but to my suprise app.config.assets
was still a truthy value without the sprockets railtie.
In our engine we check if app.config.assets
before activating our code. But it seems like that check will always return true.
With the sprockets railtie commented, the if app.config.assets
succeeded, but there was an exception on app.assets.register_engine
.
Should we come up with a different "do they have sprockets" check, or is it reasonable to assume that if they are trying to use this gem that they are already using sprockets and we can omit the check altogether?
Hello, i am learning how to use angularjs routing and templating, and i have come across a problem. I have added the gem in Gemfile, added //= require angular-rails-templates
in application.js, and added the dependancy in my main angular.module
angular.module('authentication', ['authenticationModule','ngRoute','templates'])
.config(['$routeProvider',function($provider){
$provider
.when('/sign_in', { templateUrl: '/assets/signin.html', controller: 'redirectCtrl'})
// .when('/sign_up', { templateUrl: 'templates/signup.html.erb', controller: 'redirectCtrl1'})
.controller('redirectCtrl', function($location) {
$location.path('/sign_in')
})
.controller('redirectCtrl1', function($location) {
$location.path('/sign_up')
})
My signin.html is located in /assets/templates/signin.html
When i try to load the page, i dont get the rendered page, but instead i get this
window.AngularRailsTemplates || (window.AngularRailsTemplates = angular.module("templates", []));
window.AngularRailsTemplates.run(["$templateCache",function($templateCache) {
$templateCache.put("signin.html", "\u003cdiv ng-controller=\"authenticationCtrl\"\u003e\n\t\u003cdiv\u003e\n\t \u003ch1\u003eLogin\u003c/h1\u003e\n\t\u003c/div\u003e\n\t\u003cdiv\u003e\n\t\t\u003cdiv\u003e\n\t\t \u003cdiv\u003eEmail: \u003cinput ng-model=\"email\" type=\"email\" /\u003e\u003c/div\u003e\n\t\t \u003cdiv\u003ePassword: \u003cinput type=\"password\" ng-model=\"password\" /\u003e\u003c/div\u003e\n\n\t\t \u003cbutton ng-click=\"login()\" \u003eLogin\u003c/button\u003e\n\t\t\u003c/div\u003e\n\t\u003c/div\u003e\t\t\t\t\n\u003c/div\u003e\n");
}]);
Any solution to my problem?
Thanks in advance
for slim template, whenever it sees single quote in the template, it turns it into ' this is html encoding, not javascript encoding.
With following initializer:
AppName::Application.config.angular_templates.ignore_prefix = 'templates/'
And .nghaml
templates placed in app/assets/javascripts/templates/
Referenced like this in the application.js
:
//= require_tree ./templates
I've got following snippets included in the /assets/application.js
:
$templateCache.put("templates/template-name.html", "<content-of-template>");
Is this intended to work or I just mislooked something?
I've looked into the code and only stuff that
Cheers!
Is there a way to access an HTML file directly without having it converted to a template?
Maybe it's better to have template files with a specific extension, like x.ngt.html (ngt=ng template) and have only those converted?
Developing an app on fresh Rails 4.1.1, included angular-rails-templates according to instruction:
gem 'angular-rails-templates'
in Gemfilerequire angular-rails-templates
in application.jsrequire_tree ../templates
in application.jsangular.module
And if I try to use .slim files, it doesn't work, js-template-files are not included into the manifesto. But it works if I include .html or .html.haml files, so it is just slim.
Tilt['slim'] in console returns Slim::Template, so it shouldn't be cause of the problem. I have 'slim-rails' gem installed, of course.
What can I be possibly doing wrong?
Thank you.
Some companies will only use gems with a certain license.
The canonical and easy way to check is via the gemspec
via e.g.
spec.license = 'MIT'
# or
spec.licenses = ['MIT', 'GPL-2']
There is even a License Finder to help companies ensure all gems they use
meet their licensing needs. This tool depends on license information being available in the gemspec.
Including a license in your gemspec is a good practice, in any case.
How did I find you?
I'm using a script to collect stats on gems, originally looking for download data, but decided to collect licenses too,
and make issues for missing ones as a public service :)
https://gist.github.com/bf4/5952053#file-license_issue-rb-L13 So far it's going pretty well
Production mode with precompiling my assets works, however development mode seems to be buggy.
I've got a few partials in my assets/templates
directory:
The page I'm accessing is localhost:3000/foo
Under this setup I end up in an infinitely recursive load. The generated application.js looks valid (as in the templateCache entries look correct). HOWEVER, when I look at the templateCache in the console, my foo and modal entries contain the wrapping layout (which if it's then getting injected into the DOM would explain why I get this recursion, as it then tries to load angular again and the views again).
Running the following will print out my entire html page instead of just the partial:
tc = angular.element(document.body).injector().get("$templateCache")
tc.get("foo.html")
If I move foo.html to foo_something_else.html and I move the directives/modal.html out of the directives directory (and then update my router and templateUrl's) it works. As in this weird templateCache bug goes away. Is there something going on when the page you load matches the route? Or having sub directories? Where could templateCache be getting garbled?
I'm using angular-rails-templates v 0.1.1 and angular 1.2.16.
I'm trying to convert my html views to haml and as soon as I rename the files, I stop seeing the converted .js file.
My assets/templates/foo.html
shows up as /assets/foo.js
correctly, however my assets/templates/bar.html.haml
does not appear at all in my javascript includes. Haml is definitely working for other views such as application.html.haml in views/layouts.
Gemfile:
gem 'haml-rails'
gem 'angular-rails-templates', '~> 0.1.2'
config/initializers/angular_assets.rb:
Rails.application.assets.register_engine('.haml', Tilt::HamlTemplate)
Thanks for any help on this, I'm so close to having a sweet setup!
I recently made a change to config.angular_templates.ignore_prefix
in application.rb
. I shutdown my local server and restarted foreman. However the .js template file that gets built still includes the old path. If I modify the template (like adding a period) and then refresh the page, the template is correctly rebuilt with the new path. This is a huge hassle if I want to change ignore_prefix and need all my template files to rebuild.
We have built a ng-app for normal users.
Now, we are building a new app for admin.
The root URL for user app is "/"
The root URL for admin app is "/admin"
To use ng-view and routes in the admin-app, I wrote
$routeProvider .when('/',{ templateUrl : 'admin/admin_panel.html', controller: 'adminController' })
Then I get the error:
GET http://localhost:3000/admin/admin_panel.html 404 (Not Found)
How does one access the precompiled templates for use?
I'm using AngularJS v 1.2.0rc1 + Rails 4
// RAILS_ROOT/app/assets/javascripts/application.js
...
var app = angular.module('app', ['ngRoute', 'templates'])
app.config(function ($routeProvider) {
$routeProvider.when('/', {
controller: 'TasksController',
//templateUrl: '/view1.html' // This url works because the html file is in RAILS_ROOT/public/view1.html
//templateUrl: '/assets/javascripts/templates/view1.html' // This url crashes AngularJS
templateUrl: '/assets/templates/view1.html' // This url crashes AngularJS
}).otherwise({
redirectTo: '/'
})
})
...
I have view1.html located at:
RAILS_ROOT/public/view1.html
RAILS_ROOT/app/assets/templates/view1.html
RAILS_ROOT/app/assets/javascripts/templates/view1.html
I think it would be useful if this config option could take more than one value.
config.angular_templates.ignore_prefix = %W( templates/ buried/other_templates/ )
Hi!
I've encountered an issue with angular-rails-templates. I'm not sure if that's somehow my fault or gem's fault but here is the thing:
I have two directories in my templates
dir. My full tree looks like that:
+ /templates
+ /players
- index.ngslim
+ /videos
- index.ngslim
And now, when i'm trying to use both of these templates in my routes, just the first one (players) works. For the second one (videos), angular (or rather rails) tells me that he can't find the template file. I can circumvent that issue by renaming the second file to, for instance, index2.ngslim
.
Is that some kind of angular-rails-templates
issue or i've missed something?
Regards,
Mike
We upgraded our app to 0.1.0 and now we get this error:
NameError: uninitialized constant AngularRailsTemplates::Engine::Tilt
/home/dadavis/.rvm/gems/ruby-1.9.3-p448@foreman/gems/angular-rails-templates-0.1.0/lib/angular-rails-templates/engine.rb:13:in `block in <class:Engine>'
/home/dadavis/.rvm/gems/ruby-1.9.3-p448@foreman/gems/angular-rails-templates-0.1.0/lib/angular-rails-templates/engine.rb:10:in `each'
/home/dadavis/.rvm/gems/ruby-1.9.3-p448@foreman/gems/angular-rails-templates-0.1.0/lib/angular-rails-templates/engine.rb:10:in `<class:Engine>'
/home/dadavis/.rvm/gems/ruby-1.9.3-p448@foreman/gems/angular-rails-templates-0.1.0/lib/angular-rails-templates/engine.rb:2:in `<module:AngularRailsTemplates>'
/home/dadavis/.rvm/gems/ruby-1.9.3-p448@foreman/gems/angular-rails-templates-0.1.0/lib/angular-rails-templates/engine.rb:1:in `<top (required)>'
/home/dadavis/.rvm/gems/ruby-1.9.3-p448@foreman/gems/angular-rails-templates-0.1.0/lib/angular-rails-templates.rb:1:in `<top (required)>'
/home/dadavis/Projects/katello/lib/katello.rb:22:in `<top (required)>'
/home/dadavis/.rvm/gems/ruby-1.9.3-p448@foreman/gems/bundler-1.5.3/lib/bundler/runtime.rb:76:in `require'
/home/dadavis/.rvm/gems/ruby-1.9.3-p448@foreman/gems/bundler-1.5.3/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
/home/dadavis/.rvm/gems/ruby-1.9.3-p448@foreman/gems/bundler-1.5.3/lib/bundler/runtime.rb:72:in `each'
/home/dadavis/.rvm/gems/ruby-1.9.3-p448@foreman/gems/bundler-1.5.3/lib/bundler/runtime.rb:72:in `block in require'
/home/dadavis/.rvm/gems/ruby-1.9.3-p448@foreman/gems/bundler-1.5.3/lib/bundler/runtime.rb:61:in `each'
/home/dadavis/.rvm/gems/ruby-1.9.3-p448@foreman/gems/bundler-1.5.3/lib/bundler/runtime.rb:61:in `require'
/home/dadavis/.rvm/gems/ruby-1.9.3-p448@foreman/gems/bundler-1.5.3/lib/bundler.rb:131:in `require'
/home/dadavis/Projects/foreman/config/application.rb:22:in `<top (required)>'
/home/dadavis/Projects/foreman/Rakefile:1:in `require'
/home/dadavis/Projects/foreman/Rakefile:1:in `<top (required)>'
/home/dadavis/.rvm/gems/ruby-1.9.3-p448@foreman/bin/ruby_executable_hooks:15:in `eval'
/home/dadavis/.rvm/gems/ruby-1.9.3-p448@foreman/bin/ruby_executable_hooks:15:in `<main>'
We're running a rails engine so I think this may be part of the cause?
If template extension has ending for template engine like .html.slim
, this gem cannot properly find it and generate javascript include tag.
Oh Hai! This could be a mistake on my part, but I updated to 0.0.4, and was receiving the following js error
Uncaught Error: No module: templates
In version 0.0.3, angular-rails-templates.js.erb looked like
angular.module(<%= Rails.configuration.angular_templates.module_name.inspect %> , window.AngularRailsTemplates);
But in 0.0.4 it looks like
(empty)
I see 093e2dc -- should I be using this in a different way? The README still looks like we should be using it in the same way as 0.0.4
I have a few templates of format "my_template.html.erb". This gem, however, doesn't strip the ".erb" part and forces me to refer to them in angular code by the full name. Can ".erb" be stripped?
We installed 1.3.0-beta.19
with bower and our application now throws ngStrictDi
errors on initialization. We just removed the ng-strict-di
feature for now because the gem is supposed handle that anyways.
Hi,
I'm able to implement this gem successfully and get it to work. Awesome work, thank you! The issue I'm having is that on each of my pages, the content of the js files are appending on the view. For example:
// Angular Rails Template // source: app/assets/templates/campaigns/new.html.slim
angular.module("templates").run(["$templateCache", function($templateCache) {
$templateCache.put("campaigns/new.html", '...
This entire string will show up at the top of each page in words.
Is there a way to remove them? Thank you so much.
Hi,
I've set up angular-rails-template by following the README.
But when my Angular app tries to load my template, it doesn't request the file from the assets directory but from the URL path:
My folder structure:
app/assets/templates/dashboard/overview.html.haml
<= template to load
In my code:
.state('overview', {
url: '/overview'
templateUrl: "dashboard/overview.html"
controller: 'OverviewCtrl'
})
And when I load http://localhost:5000/users/dashboard/#/overview
, the URL ART is actually requesting is: http://localhost:5000/users/dashboard/dashboard/overview.html
, which doesn't exist, instead of http://localhost:5000/assets/dashboard/overview.html
.
My application.js file contains those two lines, in this order
//= require angular-rails-templates
//= require_tree ../templates
The gem is declared in my Gemfile.
I've required 'templates' in my Angular app.
Any idea on what I did wrong?
Thank you!
I have this weird issue i haven't identified where it comes from.
From time to time my templates, randomly decide to include the full path:
$templateCache.put("physicalsku.html", "<h3>test</h3>")
$templateCache.put("angular/templates/digitalsku.html", "<h3>test</h3>")
both of these files are in the same folder app/assets/javascripts/angular/templates
.
The directive for ignore prefix is not being used but also doesn't change this behaviour.
Hi:
I'm using the version 0.0.4 and upgrading to 0.0.5, I have an error instantiating the module
Error: [$injector:modulerr] Failed to instantiate module imasdApp due to:
[$injector:modulerr] Failed to instantiate module templates due to:
[$injector:nomod] Module 'templates' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
Not sure why but after updating my gems I started getting this error:
window.AngularRailsTemplates.run is not a function
Hi,
whenever I open a page angular says it failed to fetch a view from the templateUrl, but as I'm using this gem, angular shouldn't be trying to fetch any view, right?
I'm using /app/assets/templates
dir structure and have no register_engine
calls. I'm using however asset_sync
gem to push assets to s3 and I think it might be causing this issue.
I followed your readme and read all open/closed issues looking for a solution, but couldn't find anything that could be causing this issue. How could I debug this?
P.S.: I couldn't find a way to see the contents of $templateCache, do you know a way?
Hi I'm having an issue using angular-rails-templates with Karma.js integration tests. Angular-rails-templates requires that you include "templates" as a dependency in the main app module:
angular.module('MyApp', ['ngRoute', 'templates'...]
Karma requires that you load all angular modules used in the app in the karm.conf.js "files" list up front, however there are no angular-rails-templates js files to link to. As a result I can't load my main app module into my Karma tests, and I get this error when I try to run them:
Error: [$injector:modulerr] Failed to instantiate module MyApp due to:
Error: [$injector:modulerr] Failed to instantiate module templates due to:
Error: [$injector:nomod] Module 'templates' is not available!
Here's where the error is thrown:
describe('my_controller', function(){
beforeEach(function() {
module('MyApp'); // Error occurs here
}
});
Basically, Karma is trying to load the "MyApp" module, which depends on the "templates" dependency, which Karma does not know about. Any ideas as to how I can keep this reference to "templates" in my app's main angular.module dependency list while being able to run Karma tests against it?
Thanks!
Chrome is throwing that error when I try to include the templates module in my angular module.
mod = angular.module('myapp', ['ngRoute', 'templates']);
This is on Rails 4.0.4 with v0.0.7 of the angular-rails-templates gem.
A template named [anything].tmpl.html
throws compilation error. Used to work in 0.0.2
Have the gem running and caching both HAML and Slim templates fine. Assets compile locally, but fail on Heroku:
ExecJS::ProgramError: Unexpected token: operator (<) (line: 4691, col: 43, pos: 153744)
Error
at new JS_Parse_Error (/tmp/execjs20140512-1141-yvqedd.js:2357:10754)
at js_error (/tmp/execjs20140512-1141-yvqedd.js:2357:10973)
at croak (/tmp/execjs20140512-1141-yvqedd.js:2357:19198)
at token_error (/tmp/execjs20140512-1141-yvqedd.js:2357:19335)
Any thoughts on why that might be?
When I try to using template module in my angular app in debug console I see following output:
Uncaught Error: [$injector:modulerr] Failed to instantiate module sampleApp due to:
Error: [$injector:modulerr] Failed to instantiate module templates due to:
Error: [$injector:nomod] Module 'templates' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
http://errors.angularjs.org/1.2.3/$injector/nomod?p0=templates
at http://localhost:3000/assets/angular.js?body=1:79:12
at http://localhost:3000/assets/angular.js?body=1:1523:17
at ensure (http://localhost:3000/assets/angular.js?body=1:1448:38)
at module (http://localhost:3000/assets/angular.js?body=1:1521:14)
at http://localhost:3000/assets/angular.js?body=1:3550:22
at Array.forEach (native)
at forEach (http://localhost:3000/assets/angular.js?body=1:301:11)
at loadModules (http://localhost:3000/assets/angular.js?body=1:3544:5)
at http://localhost:3000/assets/angular.js?body=1:3551:40
at Array.forEach (native)
http://errors.angularjs.org/1.2.3/$injector/modulerr?p0=templates&p1=Error%…gular.js%3Fbody%3D1%3A3551%3A40%0A%20%20%20%20at%20Array.forEach%20(native)
at http://localhost:3000/assets/angular.js?body=1:79:12
at http://localhost:3000/assets/angular.js?body=1:3578:15
at Array.forEach (native)
at forEach (http://localhost:3000/assets/angular.js?body=1:301:11)
at loadModules (http://localhost:3000/assets/angular.js?body=1:3544:5)
at http://localhost:3000/assets/angular.js?body=1:3551:40
at Array.forEach (native)
at forEach (http://localhost:3000/assets/angular.js?body=1:301:11)
at loadModules (http://localhost:3000/assets/angular.js?body=1:3544:5)
at createInjector (http://localhost:3000/assets/angular.js?body=1:3484:11)
http://errors.angularjs.org/1.2.3/$injector/modulerr?p0=sampleApp&p1=Error%…http%3A%2F%2Flocalhost%3A3000%2Fassets%2Fangular.js%3Fbody%3D1%3A3484%3A11) angular.js?body=1:79
Rails 4.0.1, angularjs-rails gem with v1.2.3
Can you add a flag to collapse whitespace, I have a large project and I compiled the templates using the Grunt angular plugin just to see and it reduces file size significantly. It seems they are running an html minifier and it's collapsing the whitespace. Thanks!
I've added this to my assets initializer:
Rails.application.config.assets.precompile += %w(*.html */*.html *.html.erb */*.html.erb )
Doesn't work in production. Works fine in dev.
I created a angualrjs directive, in the templateurl, typed: 'angular/templates/add-question-button.html'
it shows my an error that:
Showing /Users/Ivy/dynamic-forms-system/app/views/layouts/application.html.erb where line #11 raised:
[stdin]:12:16: error: unexpected :
templateUrl: "angular/templates/add-question-button.html"
^
(in /Users/Ivy/dynamic-forms-system/app/assets/javascripts/angular/Directives/addQuestionButtonDirective.js.coffee)
I've been banging my head on this for a couple of days so I figured I'd ask here. In a Rails 3.2.16 app, in app.js I'm using //= require angular-rails-templates
and then //= require_tree ./templates
underneath. My templates directory is full of plain .html files and everything is fine and dandy when compiling on the fly in development.
However when I try to precompile assets in any environment, it seems as though the templates files are ignored. The angular.module("templates",[])
line shows up fine in the compiled, minified app.js file, but nothing after that. It just skips to the next require
d JS file in the list.
Could it be a certain environment setting that's causing this? Do you know of anything that could cause this? There are no error messages when precompiling, just no templates. I can provide environment info if requested. Thanks
file.html.slim instead of file.ngslim?
RubyMine IDE for example is configured to work with file.html.slim instead of ngslim extension.
The README says path_to_your_templates, but...
...I don't know whether that path should be absolute, or relative (and relative to what)?
...I don't know where the template files themselves should be placed.
I've tried putting them in subfolders of /app/asssets/javascripts, of /app/assets, and of /app. I've tried relative and absolute paths for all of these placements, and can't seem to figure out the expected behaviour of this module.
A bit of detail in the README about suggested places to put the assets, and/or how the module goes about finding them, would be wonderful.
Our Rails templates have always lived in:
app/assets/templates
So in Angular, it's:
.when '/landing',
templateUrl: '/assets/pages/landing.html'
But of course Angular Rails Templates is awesome 💥 , so you install it and change your router to:
.when '/landing',
templateUrl: 'pages/landing.html'
But why not code Angular Rails Templates to use the same path? That way if you:
Your templates would still work. Seems $templateCache was actually coded with that in mind.
Is that a good idea, or am I missing some simple Rails setting to easlily make it so?
I'm using angular-rails-templates
0.1.2
with a Spree app and for some reason the templates module is making its way into the Spree backed js manifest and throwing the following error. Removing the gem does indeed remedy the error. Removing //= require angular-rails-templates
in the frontend js manifest still results in the same error.
// Angular Rails Template
// source: /Users/thomas/.rvm/gems/ruby-2.1.2@gemset/gems/spree_backend-2.2.2/app/assets/javascripts/spree/backend/index.html
angular.module("templates").run(["$templateCache", function($templateCache) {
$templateCache.put("spree/backend/index.html", '<!DOCTYPE html>\n<html>\n <head>\n <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />\n <style type="text/css">\n html { height: 100% }\n body { height: 100%; margin: 0; padding: 0 }\n #map-canvas { height: 100% }\n </style>\n \n </head>\n <body>\n <div id="map-canvas"/>\n </body>\n</html>')
}]);
The script that is injected in the <head>
when the gem is included <script src="/assets/spree/backend/index.js?body=1"></script>
, Uncaught ReferenceError: angular is not defined
all default installation of the angular-rails-templates
gem.
Here is the default Spree backend js manifest https://github.com/spree/spree/blob/2-2-stable/backend/app/assets/javascripts/spree/backend.js and I am not overriding this.
Hi guys,
I'm not sure why this happens but after adding the gem and starting the rails server my angular templates are added as plain text surrounded with a span
as plain text to my view. Not even required the templates or angular-rails-templates
in my application.js
but if I do so nothing changes either.
<ng-view class="ng-scope">
<span>// Angular Rails Template
// source: app/assets/templates/apps/index.html
angular.module("templates").run(["$templateCache", function($templateCache) {
$templateCache.put("apps/index.html", '
</span>
[...]
Using angular 1.2.20 and Rails 4.14
I'm moving my haml templates from my views to my templates directory. I make use of lots of helpers. How can I get access to my helper methods?
window.AngularRailsTemplates
is ["templates", "templates", "templates", "templates", "templates", "templates", "templates", "templates", "templates", "templates", "templates", "templates", "templates"]
It seems that templates keep overwriting each other by redefining module "templates".
angular.module("templates", []).run(["$templateCache",function($templateCache) {
$templateCache.put(...)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.