Search Results

Search found 193 results on 8 pages for 'haml'.

Page 2/8 | < Previous Page | 1 2 3 4 5 6 7 8  | Next Page >

  • Manually output HAML start and end tags

    - by trobrock
    I have some code: - count = 0 - @clients.each do |client| %div{:class => "grid_2#{(" alpha" if (count % 3) == 0) || (" omega push_2" if (count % 3) == 2) || " push_1"}"}= link_to h(client.name), client - count += 1 I want to output an opening div tag right after the each statement if the (count % 3) == 0 and out put the end tag at the end of the block if the (count % 3) == 2 but I can't figure out how to get HAML to do this. Any ideas?

    Read the article

  • Validate HAML from ActiveRecord: scope/controller/helpers for link_to etc?

    - by Chris Boyle
    I like HAML. So much, in fact, that in my first Rails app, which is the usual blog/CMS thing, I want to render the body of my Page model using HAML. So here is app/views/pages/_body.html.haml: .entry-content= Haml::Engine.new(body, :format => :html5).render ...and it works (yay, recursion). What I'd like to do is validate the HAML in the body when creating or updating a Page. I can almost do that, but I'm stuck on the scope argument to render. I have this in app/models/page.rb: validates_each :body do |record, attr, value| begin Haml::Engine.new(value, :format => :html5).render(record) rescue Exception => e record.errors.add attr, "line #{(e.respond_to? :line) && e.line || 'unknown'}: #{e.message}" end end You can see I'm passing record, which is a Page, but even that doesn't have a controller, and in particular doesn't have any helpers like link_to, so as soon as a Page uses any of that it's going to fail to validate even when it would actually render just fine. So I guess I need a controller as scope for this, but accessing that from here in the model (where the validator is) is a big MVC no-no, and as such I don't think Rails gives me a way to do it. (I mean, I suppose I could stash a controller in some singleton somewhere or something, but... excuse me while I throw up.) What's the least ugly way to properly validate HAML in an ActiveRecord validator?

    Read the article

  • haml / rails: yield title with german umlauts

    - by Maxem
    Hi, I would like to do something like this in my application layout: %title= "#{yield(:sub_title)} - Page Name" and in a real view - content_for :sub_title do Übersicht # I tried &Uuml;bersicht, != "&Uuml;bersicht" and a bunch of other methods what happens is, I either get the black pound with the question mark in it - wrong encoding or the raw string (&UumI;bersicht). Does anyone know a way how to get this to work? Another requirement is that I'd like to show user generated content in the title and this content may or may not have umlauts in it. Used versions: Haml 3.0.11, Rails 3 beta4 and currently for development JRuby 1.5

    Read the article

  • Ruby methods within Javascript within HAML

    - by Josh
    I have a jQuery script that adds a new field to a form, and this field contains dynamic information from an array. The problem is that I can't figure out how to add an array.each to populate the options of the select field within the javascript without breaking the HAML indentation and causing errors. Here is my best attempt that does not work: %script(type="text/javascript") $('#mylink').click(function() { $('#mylink').after('<select> - myarray.each do |options| <option value="#{options.id}">#{options.name}</option> </select>); )}; Also tried it with the :javascript filter with no luck. EDIT: For whatever reason, I can't get the 4-space indents ( for Markdown ) working here, but I do have it indented properly.

    Read the article

  • Rails: i would need to load a haml file in a class and render in the caller

    - by Totty
    I have this: app/modules/grid_module.rb app/modules/grid.html.haml then in my view: app/views/layouts/default.html.haml I want to make a new instance of the grid_module and render it content. Its content is into the grid.html.haml and this file can only use the instance vars set in the grid_module.rb is this possible to do? (the grid name is just an example, it must be more flexible, to load the html.haml file based on the .rb class) the grid_module must has access to models too* like this: User.find_by_id(4) thanks for help

    Read the article

  • If statement with code on same block in haml, RoR

    - by Micke
    Hello, i have this Haml view: !!! strict %html{:xmlns => "http://www.w3.org/1999/xhtml"} %head %meta{:content => "text/html; charset=utf-8", "http-equiv" => "Content-Type"} %title Lighty | #{@page_title || "Home"} %body #popup Login here #fade #wrapper #container #header %a#logo{:href => "/"} #menu %ul#main %li#lighty %a{:href => "/"} Lighty %ul %li %a Link here %li#community %a{:href => "/community"} Community #content And i would like to add an if on line #16 to check if it is the currently visited page and add the class "active" to the li if it returns true. How do i write that if statement there and is there any easier way to do this? My plan now is to use a variable like @current_page and testif it @current_page == "community" and add a class if it returns right. Am i thinking wrong? any easier way to accomplish this? Thanks for your answer and sorry for my bad english.

    Read the article

  • rails + compass: advantages vs using haml + blueprint directly

    - by egarcia
    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 mixins that implement common CSS idioms, such as links with icons or horizontal lists. My solution doesn't provide anything like that. (1 point for Compass). Compass has several command-line options: you can create a rails project, but you can also "install" it on an existing rails project. A rails generator could be personalized to do the same thing, I guess. (Tie). Compass has two modes of working with blueprint: "basic" and "semantic" usage. I'm not clear about the differences between those. With my rails generator I only have one mode, but it seems enough. (Tie) Apparently, Compass is prepared to use other frameworks, besides blueprint (e.g. YUI). I could not find much documentation about this, and I'm not interested on it anyway - blueprint is ok for me (Tie). Compass' learning curve seems a bit stiff and the documentation seems sparse. Learning could be a bit difficult. On the other hand, I know the ins and outs of my own system and can use it right away. (1 point for my system). With this analysis, I'm hesitant to give Compass a try. Is my analysis correct? Are Am I missing any key points, or have I evaluated any of these points wrongly?

    Read the article

  • Multiple forms + HAML + jQuery + Javascript submit

    - by Jay Godse
    Hi. I have a HAML page that lists some links to delete "things" that looks like this %div %a.form_submit Delete Thing 1 %form{:href=>"#", :id=>'comment_1', :method=>'post', :action=>'/thing/delete'} %input{:type=>'hidden', :name=>'thingid', :value=>'1'} %input{:type=>'submit', style='display:none'} %div %a.form_submit Delete Thing 22 %form{:href=>"#", :id=>'comment_22', :method=>'post', :action=>'/thing/delete'} %input{:type=>'hidden', :name=>'thingid', :value=>'22'} %input{:type=>'submit', style='display:none'} The intention is to have a link "Delete XX" which will delete something specific. A page could have a number of these links, and each link is for a specific "thing". I also have a piece of (unobtrusive) jQuery javascript that adds a click handler to each form as follows: $('a.form_submit').click(function(event) { $('form').submit(); event.preventDefauilt(); }); This works when there is one form on a page. However, if I have more than one form on a page, how do I ensure that clicking "Delete Thing 1" will trigger a submit() event only on the form with id='comment_1'?

    Read the article

  • Error: Class 'Haml' not found... trying to use Haml (Kohaml) with Kohana

    - by Serhiy
    Can't for the life of me figure out what I'm doing wrong... Downloaded Kohaml from http://github.com/transphorm/kohaml Dropped it into modules/kohaml # My Bootstrap reference 'kohaml' => MODPATH.'kohaml', // kohaml Keep getting this error... (snapshot of the error and my modules folder) http://wellcommentedcode.com/stack_kohaml_question/ Any suggestions on what I might be doing wrong would be highly appreciated... thanks.

    Read the article

  • Rails - Why is HAML showing the full hash?

    - by Mr. Demetrius Michael
    View: !!! %html %head %title= full_title(yield(:title)) =stylesheet_link_tag "application", media: "all" =javascript_include_tag "application" =csrf_meta_tags =render 'layouts/shim' %body =render 'layouts/header' .container =flash.each do |key, value| %div{class: "alert alert-#{key}"} #{value} Controller def create @user = User.new(params[:user]) if @user.save flash[:success] = "This is Correct" redirect_to @user else flash[:wrong] = "no" render 'new' end end Regardless of the flash (:success or :wrong or otherwise) it always compiles the entire hash as html (below) Output: <!DOCTYPE html> .... <div class='container'> <div class='alert alert-wrong'>no</div> {:wrong=&gt;&quot;no&quot;} </div> </body> </html> I have no idea why {:wrong=&gt;&quot;no&quot;} is being displayed. I've been staring at this terminal for hours. What's interesting is that the hash is being outputted with the container id, but not in the alert class. It feels like an indentation problem, but I went through several permutations with no success.

    Read the article

  • How do I use Haml in a view in my new plugin?

    - by Eric
    I'm creating a new plugin for a jruby on rails application that will eventually be turned into a gem. Inside my plugin I have controllers, helpers and views. For my views I'd like to use Haml. The problem is that I can't seem to get it to recognize that they are haml templates. Is it even possible to do this? Is there a way for a plugin to have Haml as a dependency for its view? And by that I mean, I intend for the plugin that I'm creating to have a view created by the plugin, that can be used by the application developer. for example: vendor/ plugins/ my_plugin/ lib/ app/ views/ my_plugin_demo/ index.haml.html controllers/ my_plugin_demo_controller.rb helpers/ In my plugin's init.rb, I tried: require 'my_plugin' require 'haml' #doesn't seem to make a difference :( but that didn't seem to make any difference. Has anybody had any experience with this? I can't seem to find any documentation on how to make this work. Are plugin views restricted to .erb templates?

    Read the article

  • How do I get Haml to work with Rails?

    - by 24hourCoder
    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. Any help would be appreciated.

    Read the article

  • How to change color of HAML tags in NetBeans?

    - by Andrei Karpenko
    I use Aloha theme in NetBeans 6.8, everything looks cool except these blue tags in HAML files, which are unreadable. How to find a place where this blue color could be changed? P.S. I use that HAML plugin which seems to be unsupported and lacks features Screenshot: http://img.leprosorium.com/846904 (sorry, new users can't embed images)

    Read the article

  • How can I transform this haml into a table?

    - by mmr
    I have the following haml code: - @theLinks.each_index do |x| %br %form{:action=>'/Download', :method=>"post",:enctype=>"multipart/form-data"} %input{:type=>"submit", :name=>"#{@theLinks[x].url}", :value=>"Name: #{@theLinks[x].Name} Study Time: #{@theLinks[x].studyTime} Comments: #{@theLinks[x].comments}"} Basically, for each person, list the time they participated in a study and the comments on the study. Right now, this renders as a set of buttons. I'd like to render it as a table, with each row clickable in the same way (ie, using the 'post' method, so that only the haml file has to be edited without touching the rest of the files). Ideally, I'd also like to be able to sort the table by name, time, or comments, but that might be getting ahead of myself. So how can I change this list of buttons into a table with clickable rows?

    Read the article

  • Is it possible to generate plain-old XML using Haml?

    - by lsdr
    I've been working on a piece of software where I need to generate a custom XML file to send back to a client application. The current solutions on Ruby/Rails world for generating XML files are slow, at best. Using builder or event Nokogiri, while have a nice syntax and are maintainable solutions, they consume too much time and processing. I definetly could go to ERB, which provides a good speed at the expense of building the whole XML by hand. HAML is a great tool, have a nice and straight-forward syntax and is fairly fast. But I'm struggling to build pure XML files using it. Which makes me wonder, is it possible at all? Does any one have some pointers to some code or docs showing how to do this, build a full, valid XML from HAML?

    Read the article

  • Why won't ruby recognize Haml under ubuntu64 while using jekyll static blog generator?

    - by oldmanjoyce
    I have been trying, quite unsuccessfully, to run henrik's fork of the jekyll static blog generator on Ubuntu 64-bit. I just can't seem to figure this out and I've tried a bunch of different things. Originally I posted this over at stackoverflow, but this is probably the better spot for it. The base stats of my machine: Ubuntu 9.04, 64 bit, ruby 1.8.7 (2008-08-11 patchlevel 72) [x86_64-linux], rubygems 1.3.1. When I attempt to build the site, this is what happens: $ jekyll --pygments Configuration from ./_config.yml Using Sass for CSS generation You must have the haml gem installed first Using rdiscount for Markdown Building site: . - ./_site /home/chris/.gem/gems/henrik-jekyll-0.5.2/bin/../lib/jekyll/core_ext.rb:27:in `method_missing': undefined method 'header' for #, page=# ..... cut ..... (NoMethodError) from (haml):9:in `render' from /home/chris/.gem/gems/haml-2.2.3/lib/haml/engine.rb:167:in 'render' from /home/chris/.gem/gems/haml-2.2.3/lib/haml/engine.rb:167:in 'instance_eval' from /home/chris/.gem/gems/haml-2.2.3/lib/haml/engine.rb:167:in 'render' from /home/chris/.gem/gems/henrik-jekyll-0.5.2/bin/../lib/jekyll/convertible.rb:72:in 'render_haml_in_context' from /home/chris/.gem/gems/henrik-jekyll-0.5.2/bin/../lib/jekyll/convertible.rb:105:in 'do_layout' from /home/chris/.gem/gems/henrik-jekyll-0.5.2/bin/../lib/jekyll/post.rb:226:in 'render' from /home/chris/.gem/gems/henrik-jekyll-0.5.2/bin/../lib/jekyll/site.rb:172:in 'read_posts' from /home/chris/.gem/gems/henrik-jekyll-0.5.2/bin/../lib/jekyll/site.rb:171:in 'each' from /home/chris/.gem/gems/henrik-jekyll-0.5.2/bin/../lib/jekyll/site.rb:171:in 'read_posts' from /home/chris/.gem/gems/henrik-jekyll-0.5.2/bin/../lib/jekyll/site.rb:210:in 'transform_pages' from /home/chris/.gem/gems/henrik-jekyll-0.5.2/bin/../lib/jekyll/site.rb:126:in 'process' from /home/chris/.gem/gems/henrik-jekyll-0.5.2/bin/jekyll:135 from /home/chris/.gem/bin/jekyll:19:in `load' from /home/chris/.gem/bin/jekyll:19 I added spaces to the left of the ClosedStruct to enable better visibility - sorry that my inline html/formatting isn't perfect. I also cut out some middle text that is just data. $ gem list *** LOCAL GEMS *** actionmailer (2.3.4) actionpack (2.3.4) activerecord (2.3.4) activeresource (2.3.4) activesupport (2.3.4) classifier (1.3.1) directory_watcher (1.2.0) haml (2.2.3) haml-edge (2.3.27) henrik-jekyll (0.5.2) liquid (2.0.0) maruku (0.6.0) open4 (0.9.6) rack (1.0.0) rails (2.3.4) rake (0.8.7) rdiscount (1.3.5) RedCloth (4.2.2) stemmer (1.0.1) syntax (1.0.0) Some showing for path verification: $ echo $PATH /home/chris/.gem/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games $ which haml /home/chris/.gem/bin/haml $ which jekyll /home/chris/.gem/bin/jekyll

    Read the article

  • In HAML on Ruby on Rails, how to use the :sass filter?

    - by Jian Lin
    If using HAML on Ruby on Rails, then :sass #someDiv border: 3px dashed orange won't have any <style> tag around them. and then :css :sass #someDiv border: 3px dashed orange won't kick on the :sass filter, but :css :sass #someDiv border: 3px dashed orange will kick on the :sass filter, but it is outside of the <style> tag. So how can the :sass filter be used?

    Read the article

  • What is the easiest way to get an embedded upload progress bar using Ruby/Sinatra/Haml/Passenger/ngi

    - by mmr
    I have a website where people can upload 30+mb of data in a single block, and I want to be able to show them the progress of their upload without causing the web page to become unresponsive, similar to how flash uploads work in gmail. There's this question here, but I don't know if that progress bar is embedded in the page or if it's using the browser's progress bar. I'm also a bit of a web newb, so I'm not sure if it's the 'easiest'. I asked the swfupload guys how to do this here, and the answer I got is 'this tool requires some knowledge to use it' without giving me much help in figuring out where to get started. I also asked this question on ServerFault, and got no response, so maybe that was the wrong place to ask. I'm all for learning new things and so forth, but there are a lot of potential pathways to take here. Where should I start, and what do I need to know to make everything work with sinatra, haml, ruby, passenger, and nginx? Thanks!

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8  | Next Page >