haml

How could I escape a & in Haml so that it compiles to & instead of &? (Haml noob)

陌路散爱 提交于 2019-11-29 12:08:16
I am trying to use the Icomoon icon font with Haml and can't seem to find a way to escape the & so that it stays just an & instead of & . The Icomoon font allows you to use HTML entities with a data-icon="" attribute. Works smooth as butter in HTML and even in a Haml file if I just do a straight HTML link. However, since I'm learning Haml I thought I'd see if anyone on here would like to recommend the best way to approach this. Here's a sample of what happens. This is the original Haml: %a(href='/posts' data-icon="&#x0026" aria-hidden='true') This is how it compiles: <a aria-hidden='true' data

Cocoon add association, how to limit number of associations

佐手、 提交于 2019-11-29 07:21:35
I am creating a system that stores cards using Ruby/Rails/HAML - In this case there is a Card class that has many Colours (this is also a class). When creating and editing a card I am using the Cocoon gem to allow me to dynamically add colour associations. The problem I am having is that in the Card model, a card is limited to having a maximum of 5 colours. Yet the interface allows adding of unlimited colours resulting in an error. Is there a way in Cocoon to limit the number of associations that can be added to a form, so that this limit is not exceeded? This is the code for a form to add

Haml - how do I force tag attributes to use double quotes only AND how do I order tag attributes the way I want?

北战南征 提交于 2019-11-29 07:03:14
问题 I use staticmatic for templates I use later with PHP. There is an odd situation where some tag attributes have single quotes, while some have double quotation marks. I would like all of them to have double quotes exclusively (not that it matters I guess, but I want them like that!) For example, haml code: !!! XML %html{html_attrs('hr-HR')} %head %title Some title %meta{'http-equiv' => 'Content-Type', :content => 'text/html; charset=utf-8'}/ %meta{'name' => "description", :content => 'Some

Best way to require Haml on Rails3 engines

纵然是瞬间 提交于 2019-11-29 06:58:56
I'm developing a Rails3 engine application, and I want to use Haml for the views. First, what I have done was to add this to the engine Gemfile: gem "haml" While I was testing my engine, it was working OK (I have used https://github.com/josevalim/enginex to generate the gem and test it with the dummy application). My problems started when I tried to use the engine on a real Rails application. The application does not have gem "haml" on it's own Gemfile, and so it was not initializing Haml, so I was receiving template not found errors as it was not looking for the .haml views. I was thinking

How to check a check box in Haml using check_box_tag

Deadly 提交于 2019-11-29 06:06:36
Can someone tell me how to set these check boxes to checked? I'm sure it's simple, but after an hour of trying i think I need to ask! Thanks! = form_tag movies_path, :id => 'ratings_form', :method => :get do Include: - @all_ratings.each do |rating| = rating = check_box_tag "ratings[#{rating}]", = submit_tag 'Refresh', :id => 'ratings_submit' Ref check_box_tag check_box_tag "ratings[#{rating}]", 1, !!(rating.rating) Your 2nd parameter must be value of checkbox Your 3rd parameter must be a boolean condition which return true/false and depends on it checkbox is checked/unchecked Matias Yaryura

Multiple Haml Elements on Same Line

落爺英雄遲暮 提交于 2019-11-29 03:55:40
I want to be able to have two Haml elements on the same line. For example: %h1 %a{:href => '/'} Professio. That doesn't work. How would I get something like this to work without borking? edtsech Unfortunately, you cannot put two haml elements on the same line. You can achieve something similar by using inline html elements: %h1 <a href='/'>Lorem ipsum</a> Why don't you like this format? %h1 %a{:href => '/'} Professio. Another option is to write special 'helper' method (that generate an html link). For example, the link_to in Rails: %h1= link_to 'Professio', root_url Jim Garvin Late answer, but

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

余生长醉 提交于 2019-11-29 03:42:27
问题 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

add checkbox with simple_form without association with model?

徘徊边缘 提交于 2019-11-29 02:27:25
问题 How I can add checkbox with simple_form without association with model? I want to create checkbox which will handle some javascript events, but don't know? Maybe I miss something in documentation? Want't to use similar like following: = simple_form_for(resource, as: resource_name, url: session_url(resource_name), wrapper: :inline) do |f| .inputs = f.input :email, required: false, autofocus: true = f.input :password, required: false = f.input :remember_me, as: :boolean if devise_mapping

Escaping </script> tag inside javascript

心不动则不痛 提交于 2019-11-29 02:05:02
I'm using backbone, and the general way for passing the collections when the page load is window.router = new Routers.ManageRouter({store: #{@store.to_json}); which is fine and works well, until someone decides to add the text " <script>alert("owned")</script> " to one of the store fields. the last </script> obviously closes the javascript. How can this be circumvented? :javascript $(function() { window.router = new Dotz.Routers.ManageRouter({store: #{@store.to_json}}); Backbone.history.start(); }); The above outputs: <script> //<![CDATA[ $(function() { window.router = new Dotz.Routers

How to remove unwanted indent from HAML's pre tag

元气小坏坏 提交于 2019-11-29 00:25:13
问题 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> 回答1: You need to use the #preserve helper to convert the newlines in the pre to newline entities, like so: %pre.code = preserve