_
_
_ _2013-05-31 12:16:06
Ruby on Rails
_ _, 2013-05-31 12:16:06

Ruby On Rails: Serve static html from haml via Asset Pipeline?

I need to load its template in AngularJS directive via templateUrl.
I want to write the template in haml.
I want to do something like asset_url('templates/login.html.haml') so that I get generated html in response.
Enabled haml support in sprockets, after rake assets:precompile generated html appears in public.
But I still need to:
1. Make it work in dev, without precompile
2. Find out the url for dev and production, where to pick up the file
Mastodons, help me out :)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
_
_ _, 2013-05-31
@AMar4enko

The problem lay in the directory structure

/app
    /assets
        /javascripts
        /stylesheets
        /templates
           /login.html.haml

The template file was in templates.
If the templates folder is moved to javascripts, then everything starts working as it should. Including asset_url('templates/login.html.haml')

A
A22, 2014-11-05
@A22

In order to work in /app/assets/templates, it is enough to create the following initializer:

Rails.application.assets.register_mime_type 'text/html', '.html'
Rails.application.assets.register_engine '.haml', Tilt::HamlTemplate

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question