Let's say you have a form that you render a few times but you would like to customize your...
...file upload that looks like this: We assume that we have (for example) this HAML: = form_for @user do |form| %div(file-input) # This field holds your existing blob's...
...to these default templates is that they're just static files. You cannot use Haml, Rails helpers or your application layout here. If you need Rails to render your error...
...through a Rails helper, you don't get hashes. E.g. %img{:src => 'foo.png'} in Haml will produce a hashless -tag and the image can't be cached properly:
end end ) You may want to strip some whitespace around tags. In Haml templates, simply replace %br with %br>< for that. When you are done, use a spam...
...renames=25% '*.js' ':!vendor' git diff master --color-moved=dimmed_zebra --find-renames=25% '*.haml' ':!vendor' git diff master --color-moved=dimmed_zebra --find-renames=25% '*.rb' ':!vendor'
...master --color-moved=dimmed_zebra --find-renames=25% ':!*.coffee' ':!*.sass' ':!*.js' ':!*.haml' ':!*.rb' ':!vendor' git diff master --color-moved=dimmed_zebra --find-renames=25% vendor...
Rails partials have a lot of "hidden" features and this card describes some non-obvious usages of Rails Partials.
...the goodies that Rails developers are used to. Out of the box, Middleman brings Haml, Sass, helpers etc. However, it can be configured to do even better. This card is...
...notices their modification # This force-reloads them Dir['helpers/*'].each(&method(:load)) # Disable warnings Haml::TempleEngine.disable_option_validator! You might want to activate :directory_indexes. This tells Middleman to create...
...Models to move logic out of the template. Sometimes it makes sense to use .haml. It helps to write more beautiful code, but makes indentation more difficult. Understanding trim mode...
...ERB tags in your Javascript. Or you can have an ERB template which generates Haml which generates HTML. You can chain as many preprocessors as you want. When you deploy...
...some useful examples, how to add inline styles and scripts with nonce to a HAML file: %style{type: "text/css", nonce: content_security_policy_nonce} :plain body { background-color: blue; }
When your application is running on a multi-server setup, application logs are stored per server (unless you choose a...
...out which tries to use the stylesheets even though he should not. When using Haml you need to nest the above code inside an :erb section as the conditional cannot...
...be formed with Haml. Set a recommended width for the application Screen space on mobile devices is scarce but still they need to guess how wide your page is. Help...
The goal is to get Jasmine specs running in a Rails project using Webpacker, with the browser based test runner...
...it has no content, i.e. not even white space. (How to prevent whitespace in HAML) For instance, you have a badge displaying the number of unread messages in a red...
...format => 'rss' View Create a view in views/feeds/rss.rss.builder [sic]. Prefer the builder to using Haml because XML schemas can be strict about whitespace, whereas Haml is not. xml.instruct! xml.rss :version...
...simplecov gem as well. This allows to track coverage across ruby templates such as haml, erb, ... Simply set this within simplecov SimpleCov.start do enable_coverage_for_eval
If you're getting this strange error message when setting debugging breakpoints, probably HAML is the culprit. Cause As far as I could find out, the error is the result...
...of setting a breakpoint (debugger) in a helper method that's called from a haml partial. Suggestions Try putting the breakpoint into the HAML view...
...occured in Rails 2.3.5 with Haml 3.0.18 and fast_gettext 0.5.10. gettext_i18n_rails's Haml-Parser compiles the Haml code and delegates the parsing to ruby_parser. Unfortunately, ruby...
Starting from Rails 4.0, you can use a special form options helper called #collection_check_boxes. It behaves similar to...
In order to keep the controllers directory tidy, we recently started to namespace controllers. With the :controller option you can...
...order of awesomeness: Don't have whitespace between two elements! See Whitespace Removal in Haml if you're using Haml. Don't use inline-block. Use floating elements instead (don...
Sometimes you want to run a command forever, e.g. to compile a haml to html file on the console. Use this: $ while(true) do haml index.haml index.html; sleep 1.5; done
...can simply use Rails' fields_for to do things like this in your views (HAML here): - fields_for @user do |form| = form.label :email, 'E-Mail' = form.text_field :email