haml

When using HAML, is there a way to use heredoc or %Q{ … }?

…衆ロ難τιáo~ 提交于 2019-12-06 17:49:27
Maybe it can be put into a helper but the existing 500 lines of code has everything in the HAML code, so it is better to follow the existing code for the moment (for tight deadlines). I found the only way working right now is - meta_tag = %Q{\n | <meta ...>\n | <meta ...>\n | [...] \n | } | which is to use the "continuation character" and the \n at the same time. It'd be great if it can be simplified. A good way to do this would be to use the :ruby filter or load the needed content into a Ruby variable and pass it into HAML the normal way. I think this is what "the Tin Man" meant. :ruby text =

force clojure :reload

邮差的信 提交于 2019-12-06 15:41:38
I noticed that (use 'somemodule :reload) doesn't reload the module if the .clj file was not modified. However I have an usecase for forcing the reload of the module even if the file isn't changed. I created a haml macro for clojure which reads an external file and generates clojure code. ( http://www.coldcode.net/2010/10/haml-macro-for-clojure.html ) I would like thus to be able to reload the clojure module regardless of the file timestamp. Does anybody know if it's possible? (I would like to avoid touching the file from outside of my editor) EDIT: I use clojure 1.2, leiningen 1.3.1 :reload

Difference between 'for' and 'each' Iterators on Ruby on Rails [duplicate]

时间秒杀一切 提交于 2019-12-06 11:12:39
This question already has answers here : “for” vs “each” in Ruby (9 answers) Closed 3 years ago . I have some doubts about the diference beetwen 'for' and 'each' Iterators on Ruby on rails. I have this case, how is the best practice for this? Def(method) present in the application_helper.rb file: def milestone_icons icons = ["", "icon-world", "icon-star-twohdd-o", "icon-users", "icon-notification", "icon-clock", "icon-eye", "icon-like-filled", "icon-credit-card", "icon-bell" ] end Select present in the haml file: %select.js-select-icons{style: 'width: 50px', name: 'milestone[icon]'} - for icon

Import HTML snippets in HAML?

瘦欲@ 提交于 2019-12-06 05:12:32
Is there a way to import HTML snippets or HAML snippets into a HAML file similar to a PHP include ? Basically have snippets of HTML for different modules (navigation, footer, carousels, et) in separate files (nav.haml, footer.haml, etc) that can be imported into haml files, so when the haml files are translated into HTML, the imported files HTML is translated as well. Example: body import(path/to/nav.haml) .container HAML CODE import(path/to/footer.haml) Yes, sir. It's called a partial. body =render 'nav' .container -# HAML CODE =render 'footer' By convention, partials would follow this naming

accessing Ruby variable(from model or controller) in SASS

元气小坏坏 提交于 2019-12-06 02:03:47
问题 Is there a way to access Ruby variables in SASS or do I have to make a custom function for it? What I'm trying to do is to generate a stylesheet for each user so in the controller, I do something like: def show respond_to do |format| format.css{render :partial => "styles"} end end then in the view name _styles.haml I do this: :sass #header :background url(user.banner.url) is this possible at all? *Apparently it isn't: http://sass-lang.com/docs/yardoc/file.FAQ.html#q-ruby-code Is there a way

How do I close the container <div> in a loop?

别说谁变了你拦得住时间么 提交于 2019-12-05 19:35:50
I have a list of products and I want to show an ad in the product feed. I want something like: <div id="container"> <div id="product">Bla..</div> <div id="product">Bla..</div> <div id="product">Bla..</div> </div> <div id="add"> Adsense Stuff </div> <div id="container"> <div id="product">Bla..</div> <div id="product">Bla..</div> <div id="product">Bla..</div> <div id="product">Bla..</div> <div id="product">Bla..</div> </div> In ERB, I would have: <div id="container"> <% productes.each_with_index do |product,index| %> <div id="product"><%= product %></div> <% if index == 2 %> </div> <div id="add"

ActionView::MissingTemplate

血红的双手。 提交于 2019-12-05 18:15:59
I am facing this runtime error after deploying mysite to VPS. note that in my local machine every thing is working fine. when I try to access any view via controller route lets say PostsController#index I got this error Completed 500 Internal Server Error in 3ms ActionView::MissingTemplate (Missing template posts/index, application/index with {:handlers=>[:builder, :erb], :formats=>[:html], :locale=>[:en]}. Searched in: "/home//dev..com/releases/20120413023845/app/views" ): app/controllers/posts_controller.rb:7:in `index' I am thinking that haml is the cause of the problem but I am not sure

How can I use Cloudinary to output a url with transformation as a string?

旧城冷巷雨未停 提交于 2019-12-05 16:04:55
I'll preface this by saying that may be approaching this incorrectly. What I'm trying to do is pass the url w/transformation into JS using a data- attribute. Currently, I'm using the following to generate the image tag: = cl_image_tag(image.asset.filename.to_s, transformation: "scroller", :"data-medium" => image.asset.filename.to_s) Which produces this: <img src="http://res.cloudinary.com/bucket/image/upload/t_scroller/v1373070863/s1ufy3nygii85ytoeent.jpg" data-medium="s1ufy3nygii85ytoeent.jpg"> What I'd like to be able to do is have it output this (Utilizing the t_medium named transition I've

Sublime colorize :javascript block in haml

烂漫一生 提交于 2019-12-05 12:18:37
问题 I have sublime 2/3 and the colorize inside a :javascript block doesn't work fine. The package is this https://sublime.wbond.net/packages/Haml Actually they says that: "Text inside Ruby, ERB, Javascript, Sass, and CSS filters are now properly recognized so you get all the syntax highlighting, snippets, commands, etc." but in sublime it doesn't work. 回答1: For me, sublime 3, comes installed with Rails package. This also provide "Ruby Haml". If you press ctrl + alt + p and type haml you will

Ruby best practice : if not empty each do else in one operator

做~自己de王妃 提交于 2019-12-05 11:25:28
问题 1.I can't find an elegant way to write this code: if array.empty? # process empty array else array.each do |el| # process el end end I'd like to have one loop, without writing array twice. I read this, but there is no solution good enough. 2. I am actually in an HAML template. Same question. - if array.empty? %p No result - else %ul - array.each do |el| %li el 回答1: What about? array.each do |x| #... puts "x",x end.empty? and begin puts "empty!" end 回答2: The cleanest way I've seen this done in