haml

Any way to avoid haml code duplication without creating new file?

删除回忆录丶 提交于 2019-12-11 04:34:26
问题 I have the following code in a .haml template file in a Sinatra app: - if(@order == 'inverse') - @list.reverse_each do |item| .item %span.action-move(data-icon="o") .detail.title=item[0] .detail.content=item[1] %span.action-delete(data-icon="d") - else - @list.each do |item| .item %span.action-move(data-icon="o") .detail.title=item[0] .detail.content=item[1] %span.action-delete(data-icon="d") As you can see, 5 lines of code are identical. Is there a way that I can refactor this code to avoid

Rails3.1 engine: can't get SLIM or HAML to work in test/dummy app

老子叫甜甜 提交于 2019-12-11 03:28:44
问题 I'm developing a Rails 3.1 engine, and to integration test it I want to use SLIM instead of plain ol' ERB. So I tried to simply add s.add_development_dependency "slim" to my .gemspec file, but when renaming my index.html.erb file to index.html.slim , Rails complains: Missing template dummy/index, application/index with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder]}. Searched in: * "/Users/josh/Documents/Work/Sientia/iq_menu/full/spec/dummy/app/views" * "/Users/josh/Documents

How to use NHaml in MVC 4?

爱⌒轻易说出口 提交于 2019-12-11 03:28:09
问题 I have used haml in Ruby on Rails, and I found a haml version in .Net called NHaml, I am tired to search how to implement NHaml in a web application, I read this article: http://weblogs.asp.net/stephenwalther/asp-net-mvc-tip-35-use-the-nhaml-view-engine but I can't complete the steps because I have an error with this line ControllerBuilder.Current.SetControllerFactory(new NHamlControllerFactory()); I think that the tutorial is for a old version, I need to use Html in MVC 4, really I don't

Add the % on tab when working with HAML on vim

你说的曾经没有我的故事 提交于 2019-12-11 03:24:16
问题 I'd like to a the ability to type h3 tab and have it output %h3 when working with haml. This would also work with other selectors such as p or section . I've installed Tim Pope's vim-haml plugin, but it doesn't seem to provide a shortcut. Have I missed something? 回答1: Two possible solution come to my head: 1) Hardcode everything using insert mode abbreviations ( aka the easy way ): function! s:haml_settings() iabbrev h3 %h3 iabbrev p %p iabbrev section %section endfunction autocmd FileType

Form tag not showing up in haml file

你说的曾经没有我的故事 提交于 2019-12-11 03:07:17
问题 I'm trying to get a form inside a modal. Everything after the form tag shows up, but not the actual form tag there for can't be submitted. I am using the same form in other pages and it does work except here. AdGroups/edit.html.haml %div(id="openModal" class="modalDialog") %div %a(href="#close" title="Close" class="close") %div = form_tag car_path, :url => {:controller => 'cars', :action => 'create'}, :html => {:multipart => true,:id =>'car-form'} do |f| %div(class="control-group") = label

Working with CodeKit and haml/PHP

纵饮孤独 提交于 2019-12-11 02:32:49
问题 in my latests projects I have use Rails. Now I have to do something in PHP (which I actually hate, or love too much Ruby syntax). So now I am very used to work with Sass and haml, which I also love. So I bought CodeKit for doing things outside rails framework. Wanted just to know if there is any option for use haml in PHP files, or PHP in haml files, and that the file compiles with CodeKit, even having PHP. 回答1: You can use the :plain filter to preserve the php, it does not parse the filtered

How do I undo Rails template generation in Haml?

笑着哭i 提交于 2019-12-11 02:32:34
问题 I installed a new gem to my Rails project - 'phrasing' - which has gem dependencies on multiple Haml gems. I need the gem (it is adding some phenomenal functionality to my project), and need the dependencies to be installed, but now when I run rails generate scaffold , all of the view templates are generated in Haml rather than ERB. I need views to continue to be generated in ERB. I reviewed several previous StackOverflow articles, but most focus on converting TO Haml, and the answers around

haml, link_to helper, and I18n in the same sentence

给你一囗甜甜゛ 提交于 2019-12-11 01:28:40
问题 Here is the markup I'm trying to get: <p>View more <a href="/clinics/integratedclinic">clinic information</a> including physicians, locations, directions, documents, and more.</p> I'm using haml, yaml, and Rails (oh my!). In order to do this with localization, I have to have this yaml: en: view_more: View more link: clinic information details: including physicians, locations, directions, documents, and more. And put my haml on 3 lines like: %p = I18n.t('view_more') = link_to I18n.t('link'),

ActionView::MissingTemplate with HAML

筅森魡賤 提交于 2019-12-11 00:57:11
问题 I'm getting Ruby on Rails set up on a fresh installation of Snow Leopard. After battling (and beating) MySQL and Sphinx problems, I'm stuck on a stupid error related to HAML. Essentially I'm getting a missing template error for every view that uses HAML. I can add a blank xxx.html.erb file and and a (blank) page loads fine. But xxx.html.haml throws the error, even though that file definitely exists in the appropriate directory. Here is the error from the development server: ActionView:

Rails 3.2.1: Calling undefined method in view causes test to hang for 30+ seconds

ぐ巨炮叔叔 提交于 2019-12-10 23:29:38
问题 I'm upgrading my app from 3.0.9 to 3.2.1 (ruby 1.9.3-p0, rvm, bundler) and one thing that I haven't been able to track down yet is this problem. I have a controller spec (in spec/controllers) that renders views for each example. The template that it renders can have any undefined method (like calling "- blahblah" in the haml) and it causes the test to hang for over 30 seconds. Here is the error: undefined local variable or method `blahblahblah' for #<#<Class:0x007fa84f76cc90>:0x007fa849c578c8