diff --git a/README.markdown b/README.markdown index f16c951..87a2726 100644 --- a/README.markdown +++ b/README.markdown @@ -223,6 +223,26 @@ The behavior of `=` depends on the setting of the `escapeHtmlByDefault` configur Haml(src, {escapeHtmlByDefault: true}) +## Multi Lines +Attributes can be declared on multiple lines + + %input(class="foo" + name="test") + %input{class: "foo", + name: "test"} + +Note the above syntax will not work with empty attributes + + %input(class="foo" + checked <-- This is not working + name="test") + +You can also explcilty use the pipe operator `|` just before line break to write content on multiple lines + + %input( | + class="foo" | + name="test" | + ) ## Plugins There are plugins in the parser for things like inline script tags, css blocks, and support for if statements and for loops. diff --git a/lib/haml.js b/lib/haml.js index b726905..0a7464d 100755 --- a/lib/haml.js +++ b/lib/haml.js @@ -493,11 +493,23 @@ var Haml; output = [], ifConditions = []; - // If lines is a string, turn it into an array + // If lines is a string, parse multilines and turn it into an array if (typeof lines === 'string') { - lines = lines.trim().replace(/\n\r|\r/g, '\n').split('\n'); + lines = lines.trim() + // Multine attributes list, use | as a line breaker + lines = lines.replace(/(?