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. The project however is just a tiny static site couple of pages to build up a template set for a later integration into the ExpressionEngine CMS a php based solution.
Thank you both Jacob and Jonathan, I ultimately ended up using neither of your approaches in favour of using middleman , hence the answer to my own question. For those reading this topic having a similar question in mind, the reason I like middleman so much is that it effectively combines my entire workflow into 1 mini-server app. With the help of a little nice script that I found here you can start a process that recognizes any changes to your haml file.
Maybee a bit more manual that you'd like, but you could always install the fs-events gem and do something along the lines of. Although you've apparently found what you were looking for I'll still post another approach because middleman might not be the perfect solution for everyone.
My approach uses Rake. I've written a simple rakefile including a 'watch' task that recompiles my sass or compass and haml files whenever a file changes. Plus it reloads the browser preview : I don't know if middleman can do that. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more.
Ask Question. Asked 10 years, 9 months ago. Active 8 years, 8 months ago. Viewed 12k times. Is there even something like this out there? Branches Tags. Could not load branches. Could not load tags. Latest commit. Git stats commits. Failed to load latest commit information. View code. Installation You can install the pluggin by adding lein-haml-sass to your project.
Haml Coffee implements the Haml Spec to ensure some degree of compatibility to other Haml implementations and the following sections are fully compatible to Ruby Haml:. Please consult the official Haml reference for more details. Haml Coffee supports both Ruby 1. So the following Ruby 1. Haml Coffee supports a small subset of the Ruby Haml helpers. Haml Coffee supports object references, but they are implemented slightly different due to the underlying runtime and different code style for CoffeeScript.
Square brackets contain a CoffeeScript object or class that is used to set the class and id of that tag. Additionally, the second argument if present will be used as a prefix for both the id and class attributes. If the user object is for example a Backbone model with the id of This will look up the specified template and include it. Haml and CoffeeScript are a winning team, both use indention for blocks and are a perfect match for this reason.
You can use CoffeeScript instead of Ruby in your Haml tags and the attributes. When you define an attribute value without putting it into quotes single or double quotes , it's considered to be CoffeeScript code to be run at render time. By default, attributes values from CoffeeScript code are escaped before inserting into the document. You can change this behaviour by setting the appropriate compiler option.
More fancy stuff can be done when use interpolation within a double quoted attribute value:. But think twice about it before putting such fancy stuff into your template, there are better places like models, views or helpers to put heavy logic into. You can define your attributes over multiple lines and the next line must not be correctly indented, so you can align them properly:.
All inserted content from running code is escaped by default. There are three variations to run code and insert its result into the document, two of them to change the escaping style chosen in the compile option:. Again, please consult the official Haml reference for more details.
Running code must be placed on a single line and unlike Ruby Haml, you cannot stretch a it over multiple lines by putting a comma at the end. However, you can use multiline endings to stretch your code over multiple lines to some extend:. Please note, that since the line is concatenated before the compilation, you cannot omit the curly braces and the commas in the above example, like you'd do in normal CoffeeScript code. Therefore it's recommended to use the CoffeeScript filter to have real multiline code blocks:.
The content of the :coffeescript filter is run when the template is rendered and doesn't output anything into the resulting document. This comes in handy when you have code to run over multiple lines and don't want to prefix each line with - :.
The following section describes all the available compiler options that you can use through the JavaScript API, as Express view option or as argument to the command line utility.
The command line arguments may be slightly different. You can see a list of all the command line arguments by executing haml-coffee --help. The Haml parser knows different HTML formats to which a given template can be rendered and it must be one of:. Doctype, self-closing tags and attributes handling depends on this setting.
All generated HTML tags are properly indented by default, so the output looks nice. This can be helpful when debugging. You can skip the indention by setting the uglify option to false. This save you some bytes and you'll have increased rendering speed. You can't change this behaviour in the template since there is no Haml markup for this to instruct the compiler to change the escaping mode.
Every output that is generated from evaluating CoffeeScript code is cleaned before inserting into the document. The default implementation converts null or undefined values into an empty string and marks real boolean values with a hidden marker character.
0コメント