haml

Rails 3.2 - haml vs. erb. Is haml faster? (february 2012)

≯℡__Kan透↙ 提交于 2019-12-04 23:46:53
I am working on a project and I am still thinking about using HAML (beautiful code, less size of view files) instead of classic ERB template. My worries why I didn't do it yet are the speed of generating views - I read an articles/benchmarks and there was almost always HAML slower than ERB - but the truth is, that the articles are 2-3 years old. So my question is, how looks the comparison these two template systems now, in the start of 2012? Here are some benchmarks from someone in Nov 2011 . You should be able to cd to your haml directory and run rake benchmark . I say "should" because you'll

angularjs with client side haml

丶灬走出姿态 提交于 2019-12-04 23:26:31
问题 I've just started using AngularJS with my Rails app and as I'm used to using haml templates within Rails I would like to do the same with AngularJS on the client side. Problem is I don't know where to read in the haml file. I have a model for investors and I'm trying to convert the 'show' template over to haml as it's the easiest to start with. Here is my AngularJS code relating to show investors.js.coffee # Setup the module & route angular.module("investor", ['investorService']) .config(['

Use JS to change <form> from remote to non-remote in Rails 3, HAML

陌路散爱 提交于 2019-12-04 17:39:45
问题 The problem is that i have a remote form that, based on condition, id like to convert to a non-remote form (using UJS), and then submit. note the form has a file upload. Here's the details: I have initially rendered the remote form using = form_for @myobj, :url => {:action=>"remoteAction", :controller=>"myobjects"}, :remote => true do |f| ... (f.fields....) which produces the HTML: <form id="new_myobj" class="new_myobj" method="post" accept-charset="UTF-8" data-remote="true" action="

Match an option in select form with boolean values

心已入冬 提交于 2019-12-04 16:47:20
问题 I have the following piece of code %br = f.label :active, 'Status' = f.select :active, ['Active','Inactive'] Symbol :active is a boolean type var. How can i match Active => 1/True, and Inactive => 0/False , for the database adding. Sorry for the newbie question, but i can't figure it out. 回答1: You can provide a pair of values for each options: first will be used as label (inner text of <option> tag), second will be used as a value attribute: = f.select :active, [['Active', true], ['Inactive',

Rails: Is it possible to write view helpers with HAML syntax?

耗尽温柔 提交于 2019-12-04 16:01:24
问题 During refactoring it would be quite handy just to copy part of HAML template and paste it to helper's code. Currently in such cases 1) I have to rewrite that part of view from scratch 2) I have to use that verbose syntax like content_tag or haml_tag. I know that it's possible to define partials with HAML systax that will serve as helper. Though 1) as for me it's inconvinient to create a separate file for each small tiny function 2) invocation syntax for partial is quite verbose. Ideally i'd

How to add an image to the contents using HAML?

泄露秘密 提交于 2019-12-04 15:36:03
问题 New to this tagging language, and I'm having trouble finding documentation mentioning how to work with images. An example or two would be fantastic. Btw, I did refer to this discussion, but not sure if that's what I need. 回答1: Outside any kind of framework: %img(src="/images/loading.gif") The older, more verbose but flexible syntax: %img{:src => "/images/loading.gif"} If you’re using Rails, it will generate the tag itself: =image_tag "loading.gif" 来源: https://stackoverflow.com/questions

haml with markdown claims rdiscount not found

依然范特西╮ 提交于 2019-12-04 13:42:23
问题 I've specified gem 'haml' gem 'rdiscount' in my Gemfile and ran bundle install The relevant code is .welcome-message :markdown Welcome **#{current_user.email}** When I access the page I get Can't run Markdown filter; required 'rdiscount' or 'peg_markdown' or 'maruku' or 'bluecloth', but none were found I'm using rails 3.0.5, what am I missing? 回答1: Turns out I'm an idiot. All that was needed was to restart the server. Carry on everyone. 来源: https://stackoverflow.com/questions/5424504/haml

How to write if-condition in Haml?

醉酒当歌 提交于 2019-12-04 07:50:38
问题 How to write if and if - else statements in Haml for a Ruby on Rails application? 回答1: HAML is indentation based , and the parser can be tricky.You don't need to use "- end" in Haml. Use indentation instead.In Haml,a block begins whenever the indentation is increased after a Ruby evaluation command. It ends when the indentation decreases.Sample if else block as follows. - if condition = something - else = something_else A practical example - if current_user = link_to 'Logout', logout_path -

generating css file from new sass format (scss) with sinatra and haml

瘦欲@ 提交于 2019-12-04 06:56:24
I am writing a sinatra app with haml and sass. When I try to link in the stylesheet with a scss extension located in my views folder I get the following error: NoMethodError at /nav.css undefined method `scss' Here is my get method get '/nav.css' do content_type 'text/css', :charset => 'utf-8' scss :nav end I have only gotten this to work when I switch to the older sass syntax. I also have to change the nav.scss to nav.sass and the get method to sass :nav I have also tried just having sass :nav with nav.scss and sass :nav with nav.sass but still scss syntax Excerpt from Sinatra README ## You

Loading an FLV in Facebox with jQuery for IE7 and IE8

↘锁芯ラ 提交于 2019-12-04 06:17:42
问题 It goes almost without saying, this works perfectly in Chrome, Firefox, and Safari. IE (any version) being the problem. Objective: I am trying to load JWplayer which loads an FLV from S3 in a Facebox popup. jQuery(document).ready(function($) { $('a[rel*=facebox]').facebox() }) HTML (haml): %li#videoGirl = link_to 'What is HQchannel?', '#player', :rel => 'facebox' .grid_8.omega.alpha#player{:style => 'display: none;'} :javascript var so = new SWFObject('/flash/playerTrans.swf','mpl','640px',