haml

Rack Error ― LoadError: cannot load such file

匿名 (未验证) 提交于 2019-12-03 08:44:33
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Trying to go through the tekpub rack tutorial but run into this error. Boot Error Something went wrong while loading app.ru LoadError: cannot load such file -- haiku There is a file named haiku.rb in the same directory as the app I am trying to run but I get the above error while trying to run the program. Here is the code: class EnvironmentOutput def initialize(app=nil) @app = app end def call(env) out = "" unless(@app.nil?) response = @app.call(env)[2] out+=response end env.keys.each {|key| out+="<li>#{key}=#{env[key]}</li>"} ["200",{

How to set inline style for element in HAML

白昼怎懂夜的黑 提交于 2019-12-03 08:04:07
问题 Here is my code: <div class='some' style='position: absolute; left: 300; top: 300;'>..</div> It parses only style='position: absolute' , and doesn't parse the other styles. How can I achieve this? 回答1: It would have been handy if you'd posted the HAML you're using, but this is how it's done: %div.some{ :style => "position: absolute; left: 300px; top: 300px;" } 回答2: No need to use %div : .some{ style: 'position: absolute; left: 300px; top: 300px;' } 回答3: Another approach in addition to the

how do I create a table using loops and haml with ruby?

社会主义新天地 提交于 2019-12-03 06:50:25
问题 I'm trying to make an html table that looks like this: 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 My data structure is like this: @f_ary = [ 1..250] Here's my haml code: %table{:border => "1"} %tbody %tr - cnt = 0 - @f_ary.each do |f| - cnt += 1 %td= cnt - if cnt == 5 - cnt = 0 %tr My current output looks like this: <table border='1'> <tbody> <tr> <td>1</td> <td>2</td> <td>3</td> <td>4</td> <td>5</td> <tr></tr> <td>1</td> <td>2</td> <td>3</td> <td>4</td> <td>5</td> </tr> </tbody> </table> I want it to

how to run ruby in haml in javascript definition?

ε祈祈猫儿з 提交于 2019-12-03 06:41:54
how can I run ruby code inside javascript in haml? if I use var = #{message} in my example I get undefined local variable or method message when I move - message = 'it works' above :javascript everything works fine I want to run iteration .each inside :javascript . See the last code sample for what I need in final javascript code. Where I need to loop few ruby variables (or one hash of hashes of hashes?) to get this. Data (='basics') can have few elemenets. It can have children with few elements etc. SO this haml code %html %head :javascript $(document).ready(function() { - message = 'it works

Conditional HTML tag in HAML

无人久伴 提交于 2019-12-03 06:34:27
问题 How would I format HAML to output a style similar to the conditional HTML tags used for cross-browser targeting? <!doctype html> <!--[if lt IE 8]> <html class="no-js ie7 oldie" lang="en"> <![endif]--> <!--[if IE 8]> <html class="no-js ie8 oldie" lang="en"> <![endif]--> <!--[if IE 9]> <html class="no-js ie9 oldie" lang="en"> <![endif]--> <!--[if gt IE 9]><!--> <html class="no-js" lang="en"> <!--<![endif]--> If I add a conditional, it wraps entire page in the conditional as well. I thought

2 Spaces or 1 Tab, what's the standard for indentation in the Rails Community?

核能气质少年 提交于 2019-12-03 06:20:44
问题 I've noticed that most of the HTML/XML/HAML that gets generated from plugins uses 2 spaces instead of 1 tab. I use textmate and have tabs set to 4 spaces for HAML/HTML/XML and 2 spaces for Javascript/Ruby, but I only have to press the tab key once to get nice indentation. Pressing the space bar twice and delete twice seems like too much work :p. Do you manually type two spaces, or is some middle layer converting tabs to two spaces? Or do just a few of you use tabs? 回答1: 2 spaces is generally

rails + compass: advantages vs using haml + blueprint directly

坚强是说给别人听的谎言 提交于 2019-12-03 06:04:44
问题 I've got some experience using haml (+sass) on rails projects. I recently started using them with blueprintcss - the only thing I did was transform blueprint.css into a sass file, and started coding from there. I even have a rails generator that includes all this by default. It seems that Compass does what I do, and other things. I'm trying to understand what those other things are - but the documentation/tutorials weren't very clear. These are my conclusions: Compass comes with built-in sass

Partials in Coffee HAML (.hamlc)

馋奶兔 提交于 2019-12-03 05:51:20
I am using backbone.js on a rails backend with HAML Coffee , which is compiled by haml_coffee_assets . There is some duplication in my templates. Is there a way to create rails-like partials to dry up my templates? Addition: Can I do content_for(:something) in Coffee HAML? Netzpirat There is no content_for helper in Haml Coffee, but you simply can render another template within a template. Without Local Variables For example, you've a template test : %p My Partial %ul %li Is included You can include it within another template like this: %p Another template != JST['test']() %p That includes a

Conditionally setting CSS style from ruby controller

懵懂的女人 提交于 2019-12-03 05:19:48
问题 I'm trying to dynamically change (if it got clicked) a normal table header (which is a link) to another defined CSS class 'th.hilite'. This link simply sorts this column and the header should got highlighted every time a user sorts the list. The view where the class in question should be changed, looks like this: %table#mytable %thead %tr %th= link_to 'Title', mytable_path(:sort => 'title'), :id => 'title_header' My question is simply: How and where could I dynamically set the class to %th

Create a local variable in Haml only

旧巷老猫 提交于 2019-12-03 04:27:23
I'm using Haml as a quick way of prototyping layouts. This is not using Rails, Sinatra or any framework. What I want to do is declare a variable at the top and be able to call it throughout the page, similar to the way I can declare a variable in Sass and use it throughout the code. !!! 5 %body / Declare Variable - $type = 'Audio' .container{:id => "page-#{$type}"} Is this possible? Drop the $ to avoid declaring a global variable. It should work just fine. !!! 5 %body / Declare Variable - type = 'Audio' .container{:id => "page-#{type}"} 来源: https://stackoverflow.com/questions/12430993/create-a