Skip to content

Instantly share code, notes, and snippets.

@pywebdesign
Created June 10, 2015 17:47
Show Gist options
  • Save pywebdesign/4be13c02c528e0bd7b91 to your computer and use it in GitHub Desktop.
Save pywebdesign/4be13c02c528e0bd7b91 to your computer and use it in GitHub Desktop.
Very simple rails angular templates server
In the views folder:
views/
- user/
- edit.html.erb
- show.html.erb
- ...
Access a template here:
example.com/templates/user/edit
This way if some day sprocket 3 is integrated in angular-rails-templates, just drag and drop the templates folder in the assets directory, remove the route and voila.
...
get "/templates/:name", to: "templates#serve", constraints: { name: /[\/\w\.]+/ }
...
end
class TemplatesController < ApplicationController
def serve
render "templates/#{params[:name]}", layout: nil
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment