haml

Middleman: referencing URL stored in a data file from markdown

▼魔方 西西 提交于 2019-12-10 20:46:25
问题 For my Middleman-built website I have stored links and other information about all pages in a data file. data/pages.yaml : pageA: link: /some-long-url-subject-to-change.html name: PageA name info: Some other related info Then, in my HAML template ( source/test.haml ), I can print relative path to pageA with = data.pages.pageA.link . Now, I want to use markdown syntax to reference that page by its name (pageA). Example ( source/test.html.haml ): .info :markdown This is some text with a [manual

Rails Internationalization: i18n look up with nested locales directories

隐身守侯 提交于 2019-12-10 17:49:20
问题 I am trying to organize my localization files with a nested file structure so that it is easier to look up. I have followed Organization of Locale Files in rails app How do you structure i18n yaml files in Rails? but I am getting a translation missing: en.view.fruits.apple . I think that Rails is trying to only look up the translation in locales/en.yml file but not the sub-directories although, I have included them. config/application.rb: config.i18n.load_path += Dir["#{Rails.root.to_s}

Output haml content via :ruby filter

 ̄綄美尐妖づ 提交于 2019-12-10 15:35:29
问题 When I use the :ruby filter to do some simple stuff in haml, for example... :ruby to = comments > max_comments ? max_comments : comments (0...to).each do |i| comment = data[i] puts li_comment comment[0], comment[1], comment[2] end the puts statement writes the output to the console. The docs for :ruby indicate that it Creates an IO object named haml_io , anything written to it is output into the Haml document. How exactly does one use the haml_io object to write to the haml document, but not

Rails 3 / HAML: How can I output haml raw from a variable?

时光总嘲笑我的痴心妄想 提交于 2019-12-10 15:12:32
问题 I have some variables within rails that contain some divs like so: @layout_1 = " .box_1 .column_4 <br> .gutter<br> .column_4<br> .gutter<br> .column_4<br> .gutter<br> .column_4<br>" This is coming from a database, and the idea is to swap layouts on request, but how can I output the variable ( @layout_1 ) as HAML inside a HAML file ? If I were to use normal html divs, I would use <%=raw or .html_safe 回答1: you would do the same with HAML as well in your .html.haml view file. = raw @layout_1 or

yaml front matter in a haml file

霸气de小男生 提交于 2019-12-10 14:14:15
问题 I am attempting to use the haml-jekyll-extension only I do not understand how to include yaml front matter? I have the following: --- user: hello --- !!! %html %title RudyIndustries %body %h1 Hello World! {{ page.user }} but it ends up getting compiled into the following html: user: hello <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <title>RudyIndustries</title> <body> <h1>Hello World! {{ page.user }}</h1> <

How add own javascript file to nanoc?

痞子三分冷 提交于 2019-12-10 13:13:44
问题 again I have a problem with files in nanoc. This time I wanted to attach custom file slide.js to my blog but I cannot (don't know why - probably something is wrong with my routes). Here's my routes: compile '/js/*/' do # don’t filter or layout end ... route '/js/*/' do /'js'/ + item.identifier.chop + '.js' end And in the head section of my layout I've put: %script{:type => "text/javascript", :src => "/js/slide.js"}/ (yes, it's a HAML). Can anyone help me to solve this problem? It would be

How to rendering partials within a partials in middleman

柔情痞子 提交于 2019-12-10 13:06:29
问题 I have some Haml partials, many of which contain the boilerplate .container .row .col-lg-12 When I try to abstract that out ala = partial "site_section" , I get: syntax error, unexpected keyword_end, expecting end-of-input end;end;end;end I'm using ruby 2.2.2. How do I render a Haml partial within a Haml partial in Middleman? Thanks update This is apparently some kind of special case dealing with my partial (above). I have other partials-within-partials rendering just fine. update With

Rails 3: undefined method `remote_form_for'

偶尔善良 提交于 2019-12-10 12:53:03
问题 I have a fairly simple Rails remote form in HAML in a partial under shared/users: - remote_form_for :user, :url => { :controller => "users", :action => "create" } do |f| .field = f.label :name, t('name') = f.text_field :name .field = f.label :email, t('email') = f.text_field :email .actions = f.submit No matter how much I fiddle with it, this just won't work. I alway get the following error: undefined method `remote_form_for' for #<#<Class:0x1036e8e40>:0x1036dfd90> Am I doing something stupid

How do I close the container <div> in a loop?

爱⌒轻易说出口 提交于 2019-12-10 10:08:42
问题 I have a list of products and I want to show an ad in the product feed. I want something like: <div id="container"> <div id="product">Bla..</div> <div id="product">Bla..</div> <div id="product">Bla..</div> </div> <div id="add"> Adsense Stuff </div> <div id="container"> <div id="product">Bla..</div> <div id="product">Bla..</div> <div id="product">Bla..</div> <div id="product">Bla..</div> <div id="product">Bla..</div> </div> In ERB, I would have: <div id="container"> <% productes.each_with

Import HTML snippets in HAML?

巧了我就是萌 提交于 2019-12-10 09:57:36
问题 Is there a way to import HTML snippets or HAML snippets into a HAML file similar to a PHP include ? Basically have snippets of HTML for different modules (navigation, footer, carousels, et) in separate files (nav.haml, footer.haml, etc) that can be imported into haml files, so when the haml files are translated into HTML, the imported files HTML is translated as well. Example: body import(path/to/nav.haml) .container HAML CODE import(path/to/footer.haml) 回答1: Yes, sir. It's called a partial.