haml

jQuery + Ajax + Haml. js.erb files not firing

断了今生、忘了曾经 提交于 2019-11-28 12:50:32
After reading up on a few experiences, I feel this issue might need to be brought up again. Coding in Rails3, I'm trying to implement some smooth Ajax effects when a user tries to create a post on another element of my app. Here's the code I'm concerned with: app/views/posts/new.html.haml - form_for @post, :remote=>true do |f| = f.text_area :content = submit_tag "Post" app/controllers/post_controller.rb def create @comment = Post.new(params[:post]) @comment.save end app/views/posts/create.js.erb: alert("ajax worked!"); I've followed what I saw on the UJS Railscast , but nothing seems to be

Is there a way to use a Ruby loop inside of HAML's :javascript region?

谁说胖子不能爱 提交于 2019-11-28 11:58:52
Inside of HAML, can we have a loop inside the :javascript region? This will work: - 10.upto(20) do |i| :javascript document.getElementById('aDiv').innerHTML += '#{i}'; and this will not: :javascript - 10.upto(20) do |i| document.getElementById('aDiv').innerHTML += '#{i}'; can the code above also be made to work as well? this one works %script - 10.upto(20) do |i| document.getElementById('aDiv').innerHTML += '#{i}'; %html %head :javascript var foo = []; #{ limit = rand(4)+3 array = (0..limit).to_a array.map{ |i| "foo[#{i}] = #{rand(12)};" }.join ' ' } console.log(foo.length); %body Running the

Rails 3.1 - changing default scaffold views and template

烂漫一生 提交于 2019-11-28 06:33:08
I'm using rails 3.1 with Zune Foundation templates and haml. I have tried to fiend ways to change the default scaffold view templates to use css I want so I get a consistent look with all scaffold without manually changing the view. I also use simple_form. As I don't want to program my own generators, is there some easy and/or recommended ways to handle this? Johann You can override default view templates by creating your own templates in 'lib/templates/erb/scaffold' folder of your rails app. lib/templates/erb/scaffold/_form.html.erb lib/templates/erb/scaffold/edit.html.erb lib/templates/erb

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

和自甴很熟 提交于 2019-11-28 05:39:11
问题 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

How do I get Haml to work with Rails?

荒凉一梦 提交于 2019-11-28 03:14:15
I am trying to get Haml to work with my Ruby on Rails project. I am new to Ruby on Rails and I really like it. However, when I attempt to add an aplication.html.haml or index.html.haml for a view, I just receive errors. I am using NetBeans as my IDE. kch Haml with Rails 3 For Rails 3 all you need to do is add gem "haml", '3.0.25' to your Gemfile . No need to install plugin or run haml --rails . . Just: $ cd awesome-rails-3-app.git $ echo 'gem "haml"' >> Gemfile And you're done. The answers above are spot-on. You just need to put gem 'haml' in your Gemfile . One other tip that was not mentioned

Best way to require Haml on Rails3 engines

若如初见. 提交于 2019-11-28 00:38:10
问题 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

How to check a check box in Haml using check_box_tag

萝らか妹 提交于 2019-11-27 23:39:18
问题 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' 回答1: 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

Haml::SyntaxError - Illegal nesting: content can't be both given on the same line as %a and nested within it

ぐ巨炮叔叔 提交于 2019-11-27 23:01:58
I'm using "Button dropdowns" from Twitter Bootstrap with HAML. In the Bootstrap docs I have found the example: <div class="btn-group"> <a class="btn dropdown-toggle" data-toggle="dropdown" href="#"> Action <span class="caret"></span> </a> <ul class="dropdown-menu"> <!-- dropdown menu links --> </ul> </div> I have tried rewrite it using HAML: %div{:class => 'btn-group task_controller'} %a{:class => 'btn-mini dropdown-toggle', "data-toggle" => 'dropdown', :href => '#'} Action %span{:class => 'caret'} %ul{:class => 'dropdown-menu'} %a{:class => 'close_task', :name => task.name, :href => '#' }

Multiple Haml Elements on Same Line

北战南征 提交于 2019-11-27 22:12:23
问题 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? 回答1: 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

Is there a good HAML -> ERB/HTML converter?

大憨熊 提交于 2019-11-27 21:46:07
I'm looking for a reliable way to convert a HAML template to an equivalent ERB/HTML template? Has anyone come across one? I recommend you to use HAML2ERB service. It's really cool and generates valid ERB/HTML code! The benefits are: HTTPS - if you need some security for your markup; API - you could write the plugin or something else for your IDE; Simple - just put your HAML code to the textbox and click "Convert"; Project is active - the author is currently working on it. Project was tested on big HAML views (over 800 lines of markup) from the real production app and it worked fine for me.