haml

How to render a partial in sinatra view (haml in haml)?

送分小仙女□ 提交于 2019-12-02 17:37:29
I have a simple sinatra app that uses haml and sass for the views. One of the views (located in the views folder) is a partial for my navigation menu. I am trying to render it from index.haml but I get the following error: wrong number of arguments (1 for 2) I am trying to render it with the following lines in index.haml .navigation = render :partial => "nav" kfl62 EDIT: !!! OUTDATED !!! Read Jason's answer below! What are you trying works in rails ! Sinatra has no partial method. An implementation of partial on Sinatra looks like this (source gist) from github: module Haml module Helpers def

inline tag in haml

家住魔仙堡 提交于 2019-12-02 17:27:16
In html, you can do something like this <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent eget aliquet odio. Fusce id quam eu augue sollicitudin imperdiet eu ac eros. <em>Etiam nec nisi lorem</em>, ac venenatis ipsum. In sollicitudin, lectus eget varius tincidunt, felis sapien porta eros, non pellentesque dui quam vitae tellus. </p> It is nice, because the paragraph of text still looks like a paragraph in the markup. In haml, it looks like this %p Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent eget aliquet odio. Fusce id quam eu augue sollicitudin

Rails doesn't log template errors in development mode

流过昼夜 提交于 2019-12-02 16:55:06
问题 My Rails 3.2.9-app does not show any specific error information to me on errors in templates ! It doesn't matter if I use haml or erb, I am always getting "We're sorry, but something went wrong" In fact, Webrick is in development mode and if there are errors in my models or controllers, I get the full ordinary error screen. Examples Example error in my helper-template ("@resource" does not exist, must be "resource"): -> All I get is this lousy "We are sorry, but something went wrong" <%

Contact form in ruby, sinatra, and haml

試著忘記壹切 提交于 2019-12-02 16:45:53
I'm new to all three, and I'm trying to write a simple contact form for a website. The code I have come up with is below, but I know there are some fundamental problems with it (due to my inexperience with sinatra). Any help at getting this working would be appreciated, I can't seem to figure out/find the documentation for this sort of thing. haml code from the contact page: %form{:name => "email", :id => "email", :action => "/contact", :method => "post", :enctype => "text/plain"} %fieldset %ol %li %label{:for => "message[name]"} Name: %input{:type => "text", :name => "message[name]", :class =

Best strategy to use HAML template with Backbone.js

有些话、适合烂在心里 提交于 2019-12-02 14:04:38
Im getting into Backbone.js to structure the javascript code for my project and I love HAML for templating on the backend(rails), so Id like to use it for Backbone Views templating. I know there is several HAML ports to Javascript, like https://github.com/creationix/haml-js and backbone supports JST and mustache with ease. Whats the best way to use haml templating instead. Are there any downsides to using HAML on the client side? Performance, extra script load time(taken care by asset packaging tools like jammit) I know you already mentioned it but I would suggest using haml-js with Jammit.

HAML - what does the “!=” operator do?

本秂侑毒 提交于 2019-12-02 13:48:13
问题 I am looking at some seemlingly standard Haml code right now, but just noticed it starts off with a "!=", and 5 minutes of googling has failed to give me the answer for what it does: #What does the '!=' mean? != cache_content_if_not_prefetched(params) do -if product_live? =render :partial => 'products/product_tile' -else =render :partial => 'products/unavailable_product_tile' 回答1: Same as using = but doesn't sanitize the HTML See http://haml.info/docs/yardoc/file.REFERENCE.html#unescaping

Loading an FLV in Facebox with jQuery for IE7 and IE8

[亡魂溺海] 提交于 2019-12-02 11:18:24
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','360px','0'); so.addParam('allowscriptaccess','always'); so.addParam('allowfullscreen','true'); so

HAML - what does the “!=” operator do?

落花浮王杯 提交于 2019-12-02 08:45:05
I am looking at some seemlingly standard Haml code right now, but just noticed it starts off with a "!=", and 5 minutes of googling has failed to give me the answer for what it does: #What does the '!=' mean? != cache_content_if_not_prefetched(params) do -if product_live? =render :partial => 'products/product_tile' -else =render :partial => 'products/unavailable_product_tile' Same as using = but doesn't sanitize the HTML See http://haml.info/docs/yardoc/file.REFERENCE.html#unescaping_html != "Look <up>!" compiles to Look <up>! instead of Look &ltg;up> That is used for Unescaping html Read this

How to use local or instance variable in ruby code in coffeescript in haml template

萝らか妹 提交于 2019-12-02 08:12:42
I'm newer of rails and facing complex issue trying to use variable in ruby helper method in coffeescript in haml template. Here is my code in haml :coffee $('input#field').blur -> input = $('input#field').val() #{ ruby_method( input )} ruby_helper.rb def ruby_method (arg) if arg @model = Model.new(arg) end end This lead a error as below undefined local variable or method Also tried instance variable :coffee $('input#field').blur -> @input = $('input#field').val() #{ ruby_method( @input )} This can not pass it to helper method. How can I get javascript variable in ruby helper method? Thanks in

How to insert a block every several div with haml?

。_饼干妹妹 提交于 2019-12-02 07:12:27
I want to insert a div.row every three blocks in order to wrap three span together for the following haml snippet. But this code insert a <div class="row"></div> rather than wrap the .span4 . - data.apps.applications.each_with_index do |app, index| - if index%3 == 0 .row # This is the line I want to insert .span4 How could I do that in haml or in this case, erb is more suitable? I think what you want is something like this: -data.apps.applications.each_slice(3) do |apps| .row -apps.each do |app| .span4 This uses each_slice . apps is an array of three items from applications . This takes groups