slim-lang

how to install slim tm bundle in sublime2

拟墨画扇 提交于 2019-12-04 01:44:01
I would like to install the slim textmate bundle to sublime2. I went to this link slim textmate bundle I cloned it to the pristinepackage(as per the nettuts website) but nothing happened.. What am I missing?. While it's tempting to install by copying directories, you should really use the Sublime Package Manager. Install instructions are super easy - just copy and paste. After installing you can: browse other packages install packages within Sublime update packages easily One small hurdle to get over and Sublime becomes way more powerful. Victor Mota Try the following (it has worked for me):

How to render HTML inside Slim templates

你离开我真会死。 提交于 2019-12-03 10:45:59
I'm trying to render a link preceded by an icon. I'm using Slim templating engine along with Bootstrap CSS . Usually you could do this the following way: <a href="#"><i class="icon-user"></i> My Profile</a> According to Slim's documentation, we can use == to render without escaping HTML. So, translating this to Slim, I tried the following variations: li== link_to "<i class='icon-user'></i> My Profile", current_user li== link_to "#{'<i class="icon-user"></i>'.html_safe} My Profile", current_user li= link_to "#{'<i class="icon-user"></i>'.html_safe} My Profile", current_user All variations

Best way to handle data attributes in Slim

吃可爱长大的小学妹 提交于 2019-12-03 10:26:47
问题 I was evaluating Slim as a replacement for HAML in a personal project, and it doesn't appear to handle HTML5 data attributes as gracefully as HAML. I was hoping someone may have also run into this, or may have known about an option/syntax I haven't yet found in their docs. HAML allows you to define HTML 5 data attributes simply by using nested hashes like so: %a{data: {key1: 'val', key2: 'val'}} resulting in <a data-key1='val' data-key2='val'></a> 回答1: There are multiple ways in Slim As Hash

Specifying a layout and a template in a standalone (not rails) ruby app, using slim or haml

随声附和 提交于 2019-12-03 09:30:39
问题 I'm trying to do something like this in a standalone (not rails) app: layout.slim: h1 Hello .content = yield show.slim: = object.name = object.description I can't figure out how to specify a layout and a template. Is this possible with slim (or haml)? Thanks. 回答1: The layout.slim file looks like: h1 Hello .content == yield The contents.slim file looks like: = name This can be shortened, but I separated to individual steps for explanation purposes. require 'slim' # Simple class to represent an

Convert ERB template to SLIM

為{幸葍}努か 提交于 2019-12-03 06:10:06
问题 Many of my views are SLIM templates and I wish to add a vote_form partial to my app. How would I convert this partial view from ERB to SLIM? <strong class="result">Votes: <%= voteable.votes_for - voteable.votes_against %></strong> <%= form_tag user_votes_path(current_user) do |f| %> <%= radio_button_tag :thumb_direction, :up %> <%= radio_button_tag :thumb_direction, :down %> <%= hidden_field_tag :voteable, @voteable %> <%= submit_tag :vote %> <% end %> Thanks :) 回答1: How convert your .erb to

Specifying a layout and a template in a standalone (not rails) ruby app, using slim or haml

北城以北 提交于 2019-12-03 01:05:45
I'm trying to do something like this in a standalone (not rails) app: layout.slim: h1 Hello .content = yield show.slim: = object.name = object.description I can't figure out how to specify a layout and a template. Is this possible with slim (or haml)? Thanks. The layout.slim file looks like: h1 Hello .content == yield The contents.slim file looks like: = name This can be shortened, but I separated to individual steps for explanation purposes. require 'slim' # Simple class to represent an environment class Env attr_accessor :name end # Intialize it env = Env.new # Set the variable we reference

Best way to handle data attributes in Slim

谁都会走 提交于 2019-12-03 00:54:17
I was evaluating Slim as a replacement for HAML in a personal project, and it doesn't appear to handle HTML5 data attributes as gracefully as HAML. I was hoping someone may have also run into this, or may have known about an option/syntax I haven't yet found in their docs. HAML allows you to define HTML 5 data attributes simply by using nested hashes like so: %a{data: {key1: 'val', key2: 'val'}} resulting in <a data-key1='val' data-key2='val'></a> There are multiple ways in Slim As Hash Attributes which will be hyphenated if a Hash is given (e.g. data={a:1,b:2} will render as data-a="1" data-b

Convert ERB template to SLIM

不羁的心 提交于 2019-12-02 19:34:37
Many of my views are SLIM templates and I wish to add a vote_form partial to my app. How would I convert this partial view from ERB to SLIM? <strong class="result">Votes: <%= voteable.votes_for - voteable.votes_against %></strong> <%= form_tag user_votes_path(current_user) do |f| %> <%= radio_button_tag :thumb_direction, :up %> <%= radio_button_tag :thumb_direction, :down %> <%= hidden_field_tag :voteable, @voteable %> <%= submit_tag :vote %> <% end %> Thanks :) How convert your .erb to .slim : Update! 18-08-2015 You can simply use html2slim gem gem install html2slim This package include a

Rewrite template.js.erb into template.js.slim

荒凉一梦 提交于 2019-12-01 21:33:48
问题 What would the below js.erb template look like when rewritten into slim? $('#new_reservation').hide().after('<%= j render("new_reservation") %>'); 回答1: | $('#new_reservation').hide().after(' = j render("new_reservation") | '); you can check this gem for further simple conversions 回答2: lately I bumped into same problem | $('#new_reservation').hide().after('#{= j render("new_reservation")}'); maybe for someone will be helpful Rails 4.2 Ruby 2.3 回答3: Slim provides a multiline approach: | var

Rewrite template.js.erb into template.js.slim

心已入冬 提交于 2019-12-01 18:27:00
What would the below js.erb template look like when rewritten into slim? $('#new_reservation').hide().after('<%= j render("new_reservation") %>'); | $('#new_reservation').hide().after(' = j render("new_reservation") | '); you can check this gem for further simple conversions lately I bumped into same problem | $('#new_reservation').hide().after('#{= j render("new_reservation")}'); maybe for someone will be helpful Rails 4.2 Ruby 2.3 Slim provides a multiline approach: | var html = "#{ j render("new_reservation") }"; $('#new_reservation').hide().after(html); 来源: https://stackoverflow.com