haml

haml two spaces issue

我们两清 提交于 2019-12-25 00:15:47
问题 When using haml I have following problem. First I want to check one variable and after that render something else, but it still should be nested. Let me explain code: .a .b gives: <div class=a><div class=b></div></div> When I use haml if else, I can't nest .b inside .a: - if id == 3 .a{style => 'xxx'} - else .a{style => 'yyy'} .b <-- 2 spaces, otherwise it fails. but 2 spaces are causing the following issue: The problem is, because there is no end in haml, I don't know how to put .b within .a

Rails: How to render repetitive form block?

元气小坏坏 提交于 2019-12-24 21:14:52
问题 In order to not repeat myself, I would like to create a function that render a form block (text field or text area) in a specific way. I want a result like this one (using Haml, and twitter-bootstrap): .form-block.input-prepend %span.add-on> %i.icon.icon-home = f.text_field :name, :value => @store.name, :placeholder => 'Company Name' To do that, I created a file views/layouts/_form-block.html.haml where I inserted the following code: .form-block.input-prepend %span.add-on> %i{ :class => "icon

Generating Sass and Haml in Rails

北城余情 提交于 2019-12-24 15:10:01
问题 Does the current head of Rails not come with haml generators? (I know in Rails 2 you had to add a generator plugin.) Setting config.generators.template_engine = :haml doesn't work. Also, how do I switch from generating .scss to generating .sass? Setting config.generators.template_engine = :sass didn't work. I get error haml/sass [not found]. I have both installed and in my Gemfile. 回答1: In 3.0, there is no haml nor sass/scss support, you need to place them in your gemfile, and call bundler.

carrierwave image not loading into source code

 ̄綄美尐妖づ 提交于 2019-12-24 15:05:59
问题 Not sure what I'm doing wrong on this one. I've followed the Rails Cast for Carrierwave but am having a strange bug where the image isn't showing at all - the (HTML) source code is showing the image tag but nothing inside it. Portfolio Model code: class Portfolio < ActiveRecord::Base validates :title, :content, presence: true mount_uploader :feature_image, FeatureImageUploader end Feature Image Uploader code: class FeatureImageUploader < CarrierWave::Uploader::Base storage :file def store_dir

Reopen SASS Mixins

↘锁芯ラ 提交于 2019-12-24 12:16:42
问题 Is there a way to redefine SASS mixins. I want to override SASS mixins for site specific styling needs. Is there a way to do it ? 回答1: My quick bit of testing seems to show that you can override mixins without a second thought. You can't reopen them to the extent that would allow you to override only certain attributes, but you can easily replace them entirely. sample.sass: =test color: red font-weight: bold =test color: blue p +test sample.css: p { color: blue; } Note that this test was

How do i build html inside .js.haml file?

懵懂的女人 提交于 2019-12-24 10:58:33
问题 I am wondering how to eloquently return the following call in my ajax call? Where i can have break lines etc inside the append function? $(".q#{@question_id}.result_to_response") .html("#{escape_javascript(@resp)}") .append('<div><a href="#" class="continue_button">Continuez to next question</a></div>'); 回答1: My advice to you is just use jQuery templates or smthng similar for that. This way you easily generate all your templates with haml and then just append .tmpl() return value in html body

textile and maruku problem

别来无恙 提交于 2019-12-24 07:38:03
问题 I've developed custom filters for HAML (http://github.com/alec-c4/cb-haml-filters) and have a small problem with textile and maruku. Maybe you can help me with this Problem with textile with code %h2 Textile test :cbtextile h4. YouTube video http://www.youtube.com/watch?v=0_IXrjqKbE4&feature=player_embedded after parsing i see embeded youtube video inside h4 tag (there are 1 empty line between h4. and http://youtube... i mean \n\n). But on TWO empty lines (\n\n\n) - all renders correctly. In

Possible to “watch” both HAML and SASS at the same time?

拟墨画扇 提交于 2019-12-24 00:58:20
问题 I'd like to be able to update/save both my html and css on-the-fly, but I can't figure out how to watch both HAML and SASS at the same time. Thanks! 回答1: Apparently you can only use StaticMatic or some other third party stuff to watch both at the same time. 回答2: Perfect for you: a free online SASS/SCSS-HAML editor, Voyage, developed by Zhi-Qiang Lei (thanks!). Very useful for beginners to practice, and for everyone to test snippets quickly. http://voyage-editor.herokuapp.com/ Hope it helps 来源

Why is accepts_nested_attributes_for not working for me? (rails 3)

痞子三分冷 提交于 2019-12-24 00:44:13
问题 I'm using formtastic and haml on a Rails 3 application. I'm trying to make a nested form for surveys and questions, but it's just not working for me. I've watched the railscast and on it and everything, but I can't seem to make it work for my application. So right now, I have the following: models class Survey < ActiveRecord::Base attr_accessible :intro, :name, :pubdate, :enddate, :pubid belongs_to :user has_many :questions, :dependent => :destroy, :autosave => true accepts_nested_attributes

scaml “illegal nesting” error

隐身守侯 提交于 2019-12-24 00:30:04
问题 Hi I'm a total Noob at scalate/scaml (I tagged haml since scaml & haml are similar). I have some template that looks like this: -@ var customer : com.x.model.Customer !!! %html %body %p Contact: %a{:href => 'mailto:#{customer.email}'}=customer.contact The %p line is flagged with this error: org.fusesource.scalate.InvalidSyntaxException: Illegal nesting: content can't be given on the same line as html element or nested within it if the tag is closed at 16.17 回答1: In HAML, you can't provide