Mineral is a language that compiles to markup or dom. It's similar to Jade (aka Pug). Its goal is to be much smaller and simpler than pug, and integrate well with modern client side frameworks. All html is lowercase, anything starting with an uppercase letter is a mixin. arguments and parens are optional. mixins are global (less fiddling with paths).mixins
Person(firstName, lastName)
h1= firstName
h2= lastName
use mixins by putting a `+` before the name of the mixin. Arguments and parens are optional.
+Person('Jello', 'Biafra')
Conditional statements (`if`, `else if` and `else`) have no parenthesis. They will evaluate a javascript expression to determine truthyness. Mineral does not implement `case` or `unless` statements.
if 1 === 'x'
p this statement is false
else if 100 > 99
p this statement is also false, and optional
else
p this is the final branch of this logic
Iterate over objects or arrays using `for` or `while`. Mineral does not implelent the `each` statement. Here are some examples using the following JSON data.
{
count: 2,
people: [
{ first: 'Tom', last: 'Waits' },
{ first: 'Dick', last: 'Dale' }
]
}
A for loop provides the key (or index) and optionally the value for each item in an array or object.
for key, val in people
+Foo(val.first, val.last)
The value variable is optional.
for p in people
+Foo(people[p].first, people[p].last)
while loops evaluate a javascript expression until it becomes falsey.
ul
while count--
span.name= people[count].first
When the `=` symbol follows a tag, it indicates that the value should be an expression. An expression can include values from the data passed to the template or any valid javascript.
h1 = 'Hello, ' + name
Mineral detects `console.log`-like statements.
h1 = 'Hello %s', foo
To continue the text content of a tag, you can use the `|` symbol.
p Danzig is an American heavy metal band, formed in 1987 in Lodi,
| New Jersey, United States. The band is the musical outlet for singer
| and songwriter Glenn Danzig, preceded by the horror punk bands the
| Misfits and Samhain. They play in a bluesy doom-driven heavy metal
| style influenced by the early sound of Black Sabbath.[1]
For multiline textblocks, add a `.` after the tag. The compiler wont evaluate any code inside these blocks. It will also preserve whitespace.
.foo.
Hello
world.
<div class="foo">
Hello
world.
</div>
This feature is pretty important when adding javascript to a script tag.
script.
var s = 'hello, world'
alert(s)
h1 I sent you an alert.
Use any jstramsformer module. For example, `npm install --save jstransformer-marked`. Arguments and parens are optional.
:marked(gfm=true) ./readme.md
comments
Single-line
Multi-line (`.beep` and `.boop` are commented)
note Comments have no business in compiled code, so they are removed entirely. Conditional comments are no longer supported by any IE version, so they wont be supported. If for some reason you really want comments, you can use the comment tag.