haml

“[ !IE]” conditional comments in Haml

戏子无情 提交于 2019-11-26 19:46:28
问题 In a HAML doc, I have: /[if IE] This is IE /[if !IE] This is not IE The first conditional evaluates properly in IE (and presumably in Firefox and Chrome, as "This is IE" does not render in those browsers). However, The second conditional does not seem to evaluate properly in Firefox or Chrome, as "This is not IE" is not rendered. I'm guessing I've done something wrong. Any ideas? 回答1: When using IE conditional comments, there are two different types you need to be aware of. First, when the

Is there a HAML implementation for use with Python and Django

情到浓时终转凉″ 提交于 2019-11-26 18:53:27
问题 I happened to stumble across HAML, an interesting and beautiful way to mark up contents and write templates for HTML. Since I use Python and Django for my web developing need, I would like to see if there is a Python implementation of HAML (or some similar concepts -- need not be exactly identical) that can be used to replace the Django template engine. 回答1: You might be interested in SHPAML: http://shpaml.com/ I am actively maintaining it. It is a simple preprocessor, so it is not tied to

Using Haml & Sass with Eclipse

你。 提交于 2019-11-26 18:51:36
问题 Are there any plugins for eclipse that add syntax highlighting and other niceties for editing Haml and Sass? Google searches only seem to point to a dead project on lucky-dip.net. Note: it's Sass I'm most interested in. A solution for using just Sass (or something similar to it like less) in Eclipse would suit my needs. Also, I'm developing for Google App Engine (Java), using the App Engine plugin for Eclipse. So switching to another IDE isn't an option. Update: So I've got syntax

incompatible character encodings: ASCII-8BIT and UTF-8

↘锁芯ラ 提交于 2019-11-26 17:23:25
I use Ruby 1.9.2 and Rails 3.0.5 I have the following error: incompatible character encodings: ASCII-8BIT and UTF-8 It has nothing to do with the database i think. The error is happinging on this line in a view (just a div haml call): #content full stack: ActionView::Template::Error (incompatible character encodings: ASCII-8BIT and UTF-8): 21: -flash.each do |name, msg| 22: =content_tag :div, msg, :id => "flash_#{name}" 23: %div.clear 24: #content 25: = yield 26: = render :partial => "layouts/grid_right" if render_grid_right? 27: = render :partial => "layouts/footer" app/views/layouts

How can I conditionally wrap some HAML content in a tag?

谁说我不能喝 提交于 2019-11-26 17:22:57
问题 How can I use a condition to decide whether to output a surrounding tag in HAML? I'm trying to create the DRY version of the code below. - if i_should_link %a{:href => url} .foo .block .of .code - else .foo .block .of .code 回答1: You could use a partial. foo.html.haml - if i_should_link %a{:href => url} = render 'bar' - else = render 'bar' _bar.html.haml .foo .block .of .code Edit: Or you could use content for, I guess this is better because it keeps it all in the same file. - if i_should_link

Append class if condition is true in Haml

自古美人都是妖i 提交于 2019-11-26 11:51:19
问题 If post.published? .post / Post stuff Otherwise .post.gray / Post stuff I\'ve implemented this with rails helper and it seems ugly. = content_tag :div, :class => \"post\" + (\" gray\" unless post.published?).to_s do / Post stuff Second variant: = content_tag :div, :class => \"post\" + (post.published? ? \"\" : \" gray\") do / Post stuff Is there a more simple and haml-specific way? UPD. Haml-specific, but still not simple: %div{:class => \"post\" + (\" gray\" unless post.published?).to_s} /

Haml: Control whitespace around text

坚强是说给别人听的谎言 提交于 2019-11-26 11:45:58
问题 In my Rails template, I\'d like to accomplish final HTML to this effect using HAML: I will first <a href=\"http://example.com\">link somewhere</a>, then render this half of the sentence if a condition is met The template that comes close: I will first = link_to \'link somewhere\', \'http://example.com\' - if @condition , then render this half of the sentence if a condition is met You may, however, note that this produces a space between the link and the comma. Is there any practical way to

incompatible character encodings: ASCII-8BIT and UTF-8

徘徊边缘 提交于 2019-11-26 05:26:10
问题 I use Ruby 1.9.2 and Rails 3.0.5 I have the following error: incompatible character encodings: ASCII-8BIT and UTF-8 It has nothing to do with the database i think. The error is happinging on this line in a view (just a div haml call): #content full stack: ActionView::Template::Error (incompatible character encodings: ASCII-8BIT and UTF-8): 21: -flash.each do |name, msg| 22: =content_tag :div, msg, :id => \"flash_#{name}\" 23: %div.clear 24: #content 25: = yield 26: = render :partial => \

twitter bootstrap navbar fixed top overlapping site

扶醉桌前 提交于 2019-11-26 00:20:04
问题 I am using bootstrap on my site and am having issues with the navbar fixed top. When I am just using the regular navbar, everything is fine. However, when i try to switch it to navbar fixed top, all the other content on the site shifts up like the navbar isn\'t there and the navbar overlaps it. here\'s basically how i laid it out: .navbar.navbar-fixed-top .navbar-inner .container .container .row //yield content i tried to copy bootstraps examples exactly but still having this issue only when