haml

Rails Partial (Rails 3, HAML) arbitrarily slow

旧时模样 提交于 2019-12-12 21:18:53
问题 I'm using Rails 3.0.1, HAML 0.3.22, and Mongrel 1.1.5 (and MongoMapper not AR). I'm rendering a list, and each list item is it's own partial. Every time the page renders one of the list item partials takes almost 100X longer to render (and it is an arbitrarily different one each time. Also, needless to say, each item has essentially the same data). Any idea what is going on here? Should I move the logic into a block rather than a partial? Rendered shared/_head.html.haml (5.6ms) Rendered tasks

Select list (dropdown) in HAML

点点圈 提交于 2019-12-12 16:16:53
问题 I'm having trouble producing a traditional HTML dropdown box in HAML. I'm using the Yii HAML extension, so I'm sure if its a quirk with that specifically. This is the HAML I'm using ... %select %option one %option two %option three This is the HTML output I'm trying to get ... <select> <option>one</option> <option>two</option> <option>three</option> </select> 回答1: Your indent is off by one space. It's two spaces, not three. %select %option one %option two %option three 来源: https:/

HAML and Ruby loop and UL not working

一世执手 提交于 2019-12-12 14:43:07
问题 I'm trying to get this simple list working, but the ul is closing and not enclosing the li elements in the loop. Am I missing a simple way to do this? %ul.nav.nav-tabs.nav-stacked - @courses.each do |c| %li = link_to "add", { :controller => "admin/relateds", :action => "edit", :id => c.id }, :confirm => "Are you sure?" = c.coursetitle 回答1: The %li needs indentation because it is within a do block. Even if it is valid markup it will save you debugging time if you opt to use 2 or 4 spaces for

HAML -> Backbone Template, Unescaping HTML Parameters

China☆狼群 提交于 2019-12-12 14:14:03
问题 I'm using HAML to generate templates for a Backbone.js app. I need to be able to insert <%= blah %> as an html attribute a la: %a{:href => "myresources/<% id %>"} My Resource and have it output <a href='myresources/<%= id %>' >My Resource</a> in the html template. Unfortunately, HAML escapes the html parameters leaving me with <a href='#myresources/<%= id %>'>My Resource</a> According to the HAML Reference the '!' operator can be used for unescaping strings, but not within the HTML attributes

VueJS with HAML/Jade/Pug-like templating

孤者浪人 提交于 2019-12-12 12:13:50
问题 I'm using both Vue.js and HAML in my current project. The templates are parsed by HAML, converted into HTML, then parsed by Vue. For instance: #pagecontent.nonscrolling %h2 Demand forecasts %label{ for:"location-type" } Select location type %select.form-control#location-type{ v-model:"locationType" } %option{ v-bind:value:"'foo'" } Foo It works ok, but it's a bit disconcerting worrying whether all the Vue syntax will make it unscathed through the HAML parser. But I really like this type of

“\xC2” to UTF-8 in conversion from ASCII-8BIT to UTF-8

本小妞迷上赌 提交于 2019-12-12 12:09:24
问题 I have a rails project that runs fine with MRI 1.9.3. When I try to run with Rubinius I get this error in app/views/layouts/application.html.haml : "\xC2" to UTF-8 in conversion from ASCII-8BIT to UTF-8 回答1: It turns out the page had an invalid character (an interpunct '·'), which I found out with the following code (credits to this gist and this question): lines = IO.readlines("app/views/layouts/application.html.haml").map do |line| line.force_encoding('ASCII-8BIT').encode('UTF-8', :invalid

Rails's link_to return url with dot instead of slash

我的未来我决定 提交于 2019-12-12 10:11:17
问题 Rails 3.0.9 with haml gem & Ruby 1.9.2-head with rvm I have order resource. Fragment of routes.rb file resources :orders The call link_to helper with instance of the Order model return /order.2 instead of /orders/2. Fragment of order_controller.rb and index.html.haml #index.haml.html %ul - @orders.each do |item| %li= link_to item.id, item #=> <a href="/order.2">2</a> instead of <a href="/orders/2">2</a> #orders_controller.rb def index @orders = Order.all end What I do wrong? I also have

generating css file from new sass format (scss) with sinatra and haml

蹲街弑〆低调 提交于 2019-12-12 08:52:09
问题 I am writing a sinatra app with haml and sass. When I try to link in the stylesheet with a scss extension located in my views folder I get the following error: NoMethodError at /nav.css undefined method `scss' Here is my get method get '/nav.css' do content_type 'text/css', :charset => 'utf-8' scss :nav end I have only gotten this to work when I switch to the older sass syntax. I also have to change the nav.scss to nav.sass and the get method to sass :nav I have also tried just having sass

Angular2 with Haml

左心房为你撑大大i 提交于 2019-12-12 08:28:38
问题 Is it possible to use HAML as template engine in Angular 2? In Angular 2 (version 2.3.1 ) you can use scss/sass instead of css. This is a given option by angular-cli with --style . For templates the cli only allows to change between inline template by setting --inline-template . Unless it is supported, how do I have to configure my Angular 2 App (created by the angular-cli version 1.0.0-beta.26 ) to write HAML , compile it to HTML and use the HTML in the component as a templateUrl ? EDIT

How can I auto compile my HAML files into HTML files in a tiny project that doesn't run on RoR?

邮差的信 提交于 2019-12-12 08:24:52
问题 I have only today started playing with compass and haml . While I am quite familiar with the way sass works and I get the idea of what compass is for sass and how to use it, I've hit a little bit of a road block when it comes to using haml efficiently. Of course I am hoping that someone here already knows the answer to my problem and can give me a little jump start into haml . Here is what I'd like to accomplish: Auto compile my HAML files when I save them. The project however is just a tiny