Use HTML instead of HAML with Ruby on Rails Happy Seed - ruby-on-rails

How can I use html.erb instead of haml when using a rails application that is generated using happy seed?

You dont have to do anything special.
You could convert your haml code to erb using https://haml2erb.org and then create an erb file pasting the code. Also delete the haml file. This should work.

Related

Convert slim to html for use as post content in Rails

I have a blog written in rails and I write the templates in slim. I was thinking it would be awesome to write my blog post content slim in my textarea box and convert it to html before I save it to the database
Is this possible and if so how can I accomplish it?
The documentation says:
Slim uses Tilt to compile the generated code. If you want to use the
Slim template directly, you can use the Tilt interface.
And provides the following examples:
Tilt.new['template.slim'].render(scope)
Slim::Template.new('template.slim', optional_option_hash).render(scope)
Slim::Template.new(optional_option_hash) { source }.render(scope)
And I am pretty sure that something like the following also works:
Slim::Template.new(template_path).render
The complete gist of the aforementioned line is to be found here.

html.haml to html.erb converter for Rails

I inherited a bunch of html.haml views in Rails project and want them to be html.erb.
Could you suggest some automatic Rails-aware converter?
Everything I've found is a set of HTML to HAML converters that additionally do not understand Rails.
You can use this converter to convert manually, link below
https://haml2erb.org/
I don't think any automatic html to erb converter is available as of now!

How to make RubyMine parse .scss.erb correctly?

I am using Ruby on Rails 4 on RubyMine 6. I have a somefile.css.scss.erb file in app/assets/stylesheets/somefolder. I am using SCSS and I need ERB to use asset_url helper to write paths for background properties.
The problem is that when I use both SCSS and ERB extensions I get "cannot find variable" warning everywhere I use SCSS variables(In uses but not in initializations). Is there any way to make RubyMine parse .scss.erb files correctly?
It works fine. I'm just not comfortable with these warnings.
You don't need to do that. Just rename the file to somefile.css.scss and use the SCSS image-url helper.
image-url("rails.png")
is translated into
url(/assets/rails.png)

Convert html to rails helpers

I am a RoR developer. I work with a graphic designer who prepares static html/css files and forward them to me.
Then I covert those html code to haml and include them in my views.
I use http://html2haml.heroku.com/ to covert html to haml. But it doesn't covert to haml using Rails helpers.
Example:
It converts
<img src="abc.png" />
To
%img{:src => "abc.png"}/
But I need it to be converted to
=image_tag "abc.png"
The same for other Rails helpers (link_to, text_field, ...etc)
Is there anything can make my work easier and converts using helpers?
I think, there's only one solution to this: your views should be built with Rails helpers from its beginning. There's many tools that can help create static views (which become your project views then), such as Serve or Middleman. The downside is that your designer should know about Rails helpers, haml etc, but this is a classical tradeoff.

How can I use haml within a coffeescript file?

Is it possible to use haml within a coffeescript file in a rails 3.1 project?
What is the correct order of the file extensions?
My last try was that:
home.js.haml.coffescript
$ ->
alert '#{#count}'
where #count is a ruby variable.
The correct order would be home.js.coffeescript.haml—you want the file to first be evaluated as Haml to give you your variables, then compiled as CoffeeScript, then finally served as JavaScript.
However, I strongly suspect that the Haml processor will choke on some CoffeeScript syntax. It would probably be safer to use ERB, which should work for your example.

Resources