haml

“[ !IE]” conditional comments in Haml

左心房为你撑大大i 提交于 2019-11-27 19:01:44
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? When using IE conditional comments, there are two different types you need to be aware of. First, when the entire content is inside a HTML comment (between <!-- and --> ), but IE will read it because of the condition:

How do I include inline JavaScript in Haml?

纵饮孤独 提交于 2019-11-27 17:25:12
How can I write something like this to include in a template, but in Haml? <script> $(document).ready( function() { $('body').addClass( 'test' ); } ); </script> bcoughlan :javascript $(document).ready( function() { $('body').addClass( 'test' ); } ); Docs: http://haml.info/docs/yardoc/file.REFERENCE.html#javascript-filter You can actually do what Chris Chalmers does in his answer, but you must make sure that HAML doesn't parse the JavaScript. This approach is actually useful when you need to use a different type than text/javascript , which is was I needed to do for MathJax . You can use the

Is there a HAML implementation for use with Python and Django

こ雲淡風輕ζ 提交于 2019-11-27 17:09:33
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. Steve Howell 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 any other tools like Genshi. I happen to use it with Django, so there is a little bit of Django

Using Haml & Sass with Eclipse

血红的双手。 提交于 2019-11-27 17:08:13
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 highlighting now using Pascal's answer and I've installed Ruby and Compass to compile sass into css. However I

Escaping </script> tag inside javascript

孤街浪徒 提交于 2019-11-27 16:26:45
问题 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

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

寵の児 提交于 2019-11-27 15:59:09
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 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 %a{:href => url} = yield :foobar - else = yield :foobar - content_for :foobar do .foo .block .of .code I

Empty attribute with Ruby HAML

大城市里の小女人 提交于 2019-11-27 12:40:06
问题 I'm implementing Schema microformats on a Ruby project using HAML and can't figure out how to set an empty attribute on a tag. I tried nil and false, but they simply do not shown. Example: <div itemscope> I'm tring to set an empty itemscope attribute. Code added from comment by @StrangeElement: My code: .agency.premium{:itemscope => true, :itemtype => 'schema.org/ProfessionalService';} :itemscope => true seems to be the recommended approach from HAML's documentation. I get the same result as

How to Show Error Messages Next to Field

南楼画角 提交于 2019-11-27 11:44:10
问题 I have a form with input fields/labels etc. How do I get the error message to show up next to the field? instead of clumped together at the top? I am using devise, rails 3 I have this at the top of my form: = form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| - if resource.errors.any? #errorExplanation %h2 = pluralize(resource.errors.count, "error") prevented this user from being saved: %ul - resource.errors.full_messages.each do |msg| %li = msg 回答1: You

put haml tags inside link_to helper

拥有回忆 提交于 2019-11-27 11:05:02
问题 is it possible to add html-content inside a link_to helper in HAML? i tried this, but all i get is a syntax error: = link_to "Other page", "path/to/page.html" %span.icon Arrow expected output: <a href="path/to/page.html">Other Page<span class="icon">Arrow</span></a> 回答1: You should use block = link_to "path/to/page.html" do Other page %span.icon Arrow 回答2: If anyone is still using Rails 2.x on a project, it looks like the accepted answer returns the block, thus duplicating the link in the

Rendering partial with locals in Haml?

喜夏-厌秋 提交于 2019-11-27 10:48:00
问题 I am learning Haml. My view files are like: show.html.haml: .content = render 'meeting_info', :locals => { :info => @info } and _meeting_info.html.haml: .detail %table %caption Meeting Informations of = info["meeting_name"] ... When I tried running this I got an undefined local variable or method 'info' error. 回答1: Try this Without :locals and :partial .content = render 'meeting_info', :info => @info No need to specify locals. With :locals and :partial You should specify locals in following