haml

Count number of selectors in a css file

a 夏天 提交于 2019-11-27 09:35:11
问题 is there an existing plugin/app/program/script/whatever that analyzes and counts the css selectors of a file? i want to check if the reason my css file is not working in IE is because my selector count is over 4095 (which im pretty sure is not) thanks! p.s. plus points if there's a haml/sass/compass solution 回答1: The following snippet can be run in the Firebug console in Firefox to count the total number of CSS selectors (not just CSS rules) and check whether it reaches the limit of 4095

erb, haml or slim: which one do you suggest? And why? [closed]

纵然是瞬间 提交于 2019-11-27 09:06:58
问题 I am learning Rails and I have seen these template engines. I have no experience with them (only erb). But as I am a beginner, I am really confused. Which one do you suggest and why? Erb, Haml or Slim? Please tell your reason for preferring one over the others. And if you have any other recommendations, please let us know. EDIT: I am NOT looking for a winner here. I just want to hear your opinions about them, their syntax, speed of execution, and so on. 回答1: ERB is good mainly if you have a

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

允我心安 提交于 2019-11-27 07:15:54
问题 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

Using layouts in HAML files independently of Rails

不问归期 提交于 2019-11-27 06:37:43
My end goal is to create several static HTML files for hand-off to other folks. But for my workflow, I'd like to have HAML as the basic source files. In doing so, I'd hope to DRY up the process at least on my side. Now I have a lot of pages that will ultimately be sharing a common layout, and I'm wondering how to incorporate the layouts. Here's my current code: ./compile.rb #!/usr/bin/env ruby require 'rubygems' require 'rake' require 'haml' FileList.new('./src/*.html.haml').each do |filename| if filename =~ /([^\/]+)\.haml$/ File.open($1, 'w') do |f| f.write Haml::Engine.new(File.read

How to access instance variables in CoffeeScript engine inside a Slim template

烈酒焚心 提交于 2019-11-27 06:36:10
I have a Rails controller in which I am setting a instance variable - @user_name = "Some Username" In my .slim template I am using coffee engine to generate javascript and want to print out the user name from client-sie javascript code - coffee: $(document).ready -> name = "#{@user_name}" alert name But this is the javascript that is being generated?? $(document).ready(function() { var name; name = "" + this.my_name; alert(name); } How do I access controller instance variables in my CoffeeScript code?? I am tagging this as haml since I am guessing haml will have the same issue when using

Append class if condition is true in Haml

浪子不回头ぞ 提交于 2019-11-27 06:03:29
If post.published? .post / Post stuff Otherwise .post.gray / Post stuff I've implemented this with rails helper and it seems ugly. = content_tag :div, :class => "post" + (" gray" unless post.published?).to_s do / Post stuff Second variant: = content_tag :div, :class => "post" + (post.published? ? "" : " gray") do / Post stuff Is there a more simple and haml-specific way? UPD. Haml-specific, but still not simple: %div{:class => "post" + (" gray" unless post.published?).to_s} / Post stuff .post{:class => ("gray" unless post.published?)} - classes = ["post", ("gray" unless post.published?)] =

Haml: Control whitespace around text

独自空忆成欢 提交于 2019-11-27 05:50:43
In my Rails template, I'd like to accomplish final HTML to this effect using HAML: I will first <a href="http://example.com">link somewhere</a>, then render this half of the sentence if a condition is met The template that comes close: I will first = link_to 'link somewhere', 'http://example.com' - if @condition , then render this half of the sentence if a condition is met You may, however, note that this produces a space between the link and the comma. Is there any practical way to avoid this whitespace? I know there's syntax to remove whitespace around tags, but can this same syntax be

Rails 3.1 - changing default scaffold views and template

邮差的信 提交于 2019-11-27 01:23:36
问题 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 回答1: You can override default view templates by creating your own templates in 'lib/templates/erb/scaffold' folder of your rails

How do I get Haml to work with Rails?

∥☆過路亽.° 提交于 2019-11-26 23:59:03
问题 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. 回答1: 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. 回答2: The

How do I include inline JavaScript in Haml?

◇◆丶佛笑我妖孽 提交于 2019-11-26 22:34:33
问题 How can I write something like this to include in a template, but in Haml? <script> $(document).ready( function() { $('body').addClass( 'test' ); } ); </script> 回答1: :javascript $(document).ready( function() { $('body').addClass( 'test' ); } ); Docs: http://haml.info/docs/yardoc/file.REFERENCE.html#javascript-filter 回答2: You can actually do what Chris Chalmers does in his answer, but you must make sure that HAML doesn't parse the JavaScript. This approach is actually useful when you need to