haml

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

被刻印的时光 ゝ 提交于 2019-12-03 04:22:46
问题 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" 回答1: EDIT: !!! OUTDATED !!! Read Jason's answer below! What are you trying works in rails ! Sinatra has no partial method. An

Using AngularJS within Haml views of a Rails app

倖福魔咒の 提交于 2019-12-03 04:19:36
问题 I have a Rails app with Haml views. Now I want to add AngularJS to some parts of the application, but the problem is that the Haml views are rendered server-side and the AngularJS code is not working, because it is rendered client-side. Let's say I have just this in my index.html.haml: !!! %html{"ng-app" => "Test"} %head %script{:src => "http://ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular.js"} :javascript function Clock($scope) { $scope.currentTime = new Date(); } %title Welcome to

How to generate Haml views instead of erb

喜夏-厌秋 提交于 2019-12-03 04:14:03
问题 I'm building an app with Rails 2.3.4 and using script/generate controller home index to generate a controller and home page. I've got Haml installed. I get an erb file: app/views/home/index.html.erb but I'd prefer to have a Haml file generated instead, like: app/views/home/index.html.haml I recall Merb would generate .haml views instead of .erb if a haml gem was detected. Is this not available in Rails 2.3.4? I tried script/generate controller home index --haml but a "--haml" option is

inline tag in haml

不打扰是莪最后的温柔 提交于 2019-12-03 04:07:01
问题 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

Structuring of layout template in Haml

断了今生、忘了曾经 提交于 2019-12-03 03:53:15
问题 I have a web page that uses Haml for layouts. There is a separate layout file (layout.haml) which is used when rendering any actual haml page. The layout.haml looks something like -# layout.haml !!! XML !!! %html %head ... %body ... #content= yield The problem: This is of course already in the document's <body> so manipulating things in the header is not directly possible. For instance <title> is changed via @title . What is something more of a problem is the fact that every page specific

HAML: form_tag dilemma (indentation?)

匿名 (未验证) 提交于 2019-12-03 02:56:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm making "user settings form", and stuck with HAML: = form_tag('/') - [1,2,3].each do |i| = check_box_tag "accept#{i}" = submit_tag This results in "syntax error, unexpected kENSURE, expecting $end". The working variant is = form_tag('/') - [1,2,3].each do |i| = check_box_tag "accept#{i}" = submit_tag Results in <input id="accept1" name="accept1" type="checkbox" value="1" /> <input name="commit" type="submit" value="Save changes" /> <input id="accept2" name="accept2" type="checkbox" value="1" /> <input name="commit" type="submit" value=

Contact form in ruby, sinatra, and haml

左心房为你撑大大i 提交于 2019-12-03 02:54:18
问题 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

How to Generate Views for Devise in HAML

陌路散爱 提交于 2019-12-03 02:38:51
This is mine Gemfile gem 'haml' group :development do gem 'hpricot' gem 'ruby_parser' end I then executed the following statements in a terminal/command window: bundle install rails generate devise:views users -e haml or rails generate devise:views users -t = haml But creating devise views in erb. how to fix this issue? DogpatchTech Even simpler solution. I have erb2haml installed in the development section of my Gemfile, so I just run: rails generate devise:views rake haml:erb2haml # or rake haml:replace_erbs # outdated Done! Ch Zeeshan I have to do this rails generate devise:views gem

Best strategy to use HAML template with Backbone.js

心不动则不痛 提交于 2019-12-03 01:56:47
问题 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

Mustache and Haml

匿名 (未验证) 提交于 2019-12-03 01:47:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have got this haml/mustache template: {{#data}} ok {{#items}} {{#item}} %b ID: {{id}} {{/item}} {{/items}} {{/data}} And I have got Illegal nesting: nesting within plain text is illegal Error. I render it in Sinatra Mustache.render(haml(:index), hash) 回答1: I'm not sure about rendering with Sinatra, but with this command: cat example.yml foo.haml.mustache | mustache | haml -e this data file example.yml --- data: - items: - item: - id: 1 - id: 2 - id: 3 --- and template (foo.haml.mustache ): {{#data}} #ok {{#items}} {{#item}} %b ID: {{id}} {