haml

Is there a bash command for converting an entire directory to HAML from HTML?

◇◆丶佛笑我妖孽 提交于 2019-11-30 05:41:42
I'm looking to convert an entire directory of HTML to HAML so that the files have the same name but with a new extension. html2haml file.html.erb file.haml Can I run a loop so that I can convert all these files all at once so that the name is the same just the extension is changed? My files: continue_login.html.erb expired_trial.html.erb expired_trial.mobile.erb login.html.erb login.mobile.erb recover_password.html.erb signup.html.erb trial_expires_soon.html.erb trial_expires_soon.mobile.erb It's not sexy but it's working: for file in $(find . -type f -name \*.html.erb); do html2haml -e ${file

How to remove unwanted indent from HAML's pre tag

[亡魂溺海] 提交于 2019-11-30 02:46:03
I have problem with <pre> , here is my code, and the screenshot is attached below. How to remove the indents? %pre.code :escaped <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head></head> <body> <form> <input type="text" name="empID" /> <input type="submit"/> </form> </body> </html> Natalie Weizenbaum You need to use the #preserve helper to convert the newlines in the pre to newline entities, like so: %pre.code = preserve do :escaped <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3

Multiple multi-line HAML blocks

只愿长相守 提交于 2019-11-30 01:21:46
问题 Using the (intentionally) strange multi-line format for HAML, I'd like to have the following lines in my template: = call_to_helper :foo1 => 'bar1', :foo2 => 'bar2', :foo3 => 'bar3', | :foo4 => 'bar4', :foo5 => 'bar5' | -# and = call_to_helper :foo1 => 'bar1', :foo2 => 'bar2', :foo3 => 'bar3', | :foo4 => 'bar4', :foo5 => 'bar5' | However, they can not run up against one another, or they are read as one single multi-line block. -# This fails: = call_to_helper :foo1 => 'bar1', :foo2 => 'bar2',

How do I make an image link tag using haml in Rails?

主宰稳场 提交于 2019-11-29 23:28:53
I have something like this in application.html.haml: #header = image_tag("header.jpg") How do I make that link to www.google.com, for example? Thanks I do it this way: = link_to image_tag( 'header.jpg'), 'http://www.google.com' 来源: https://stackoverflow.com/questions/1202654/how-do-i-make-an-image-link-tag-using-haml-in-rails

Partial HAML templating in Ruby without Rails

寵の児 提交于 2019-11-29 23:10:47
I really don’t need the overhead of Rails for my very small project, so I’m trying to achieve this just using just plain Ruby and HAML. I want to include another HAML file inside my HAML template. But I haven’t found a good—or really usable—way of doing this. For example, I have these two HAML files: documents.haml %html %body = include(menu.haml) body %article … menu.haml %ul %li %a whatever … Include is obviously not the way to go here. But it does a nice job describing what I’m trying to achieve in this example. I've done this before, just for a quick-and-dirty template producer. The

Ruby methods within Javascript within HAML

核能气质少年 提交于 2019-11-29 21:18:37
I have a jQuery script that adds a new field to a form, and this field contains dynamic information from an array. The problem is that I can't figure out how to add an array.each to populate the options of the select field within the javascript without breaking the HAML indentation and causing errors. Here is my best attempt that does not work: %script(type="text/javascript") $('#mylink').click(function() { $('#mylink').after('<select> - myarray.each do |options| <option value="#{options.id}">#{options.name}</option> </select>); )}; Also tried it with the :javascript filter with no luck.

Convert existing html.erb to Haml [closed]

隐身守侯 提交于 2019-11-29 20:16:23
I have a rails project, the views only consist with HTML.ERB files, my client wants to convert ERB to HAML. I have too many views file. It's taking a huge amount of time to convert file by file. So that any simply way I can convert HTML to haml? I installed haml plugin under my project. mikewilliamson There you go: http://html2haml.heroku.com/ EDIT: Moved to https://html2haml.herokuapp.com/ Mike You can use from the command line html2haml html2haml your_erb_file new_haml_file If you want to convert all your files in one go, look at this article : http://shifteleven.com/articles/2008/06/08

HAML: Create container/wrapper element only if condition is true

橙三吉。 提交于 2019-11-29 18:58:01
问题 Longshot, but I'm wondering if there's any way to do something like this: %p # ONLY SHOW THIS IF LOCAL VARIABLE show_paras IS TRUE = name In other words, it always shows the content inside, but it only wraps a container around it if (some-condition) is true. 回答1: You could use raw html, but then you'd have to have the if statement both at the beginning and end: - if show_paras <p> = name - if show_paras </p> Assuming you're doing more than just = name , you could use a partial: - if show

Why does a rails app on heroku serve assets via all.css and locally via individual files

半腔热情 提交于 2019-11-29 17:24:38
问题 I'm a rails newbie, I've been trying to figure out what is going on with the stylesheets_link_tag on heroku. If I use = stylesheet_link_tag "style", :cache => true heroku uses "all.css" and does not pick up the stylesheet, but if I use = stylesheet_link_tag "style", :cache => false it serves the stylesheet using its name "style.css". Why? 回答1: This is the result of calling :cache => true on your stylesheet link tag. :cache => true takes all of the stylesheets provided and concatenates them

How to do data- attributes with haml and rails?

泪湿孤枕 提交于 2019-11-29 16:04:42
问题 I can have %a{href: '#', data_toggle_description_length: 'toggle_me_ajax'} which it gives me underscores not dashes, i.e. <a href="#" data_toggle_description_length="toggle_me_ajax"></a> However I want to have HTML5 data- attributes, i.e. <a href="#" data-toggle-description-length="toggle_me_ajax"></a> but when I try replacing underscores with dashes, i.e. %a{href: '#', data-toggle-description-length: 'toggle_me_ajax'} I get syntax errors: /home/durrantm/Dropnot/webs/rails_apps/linker/app