Attributes
Writing attributes is very straight-forward. Simply put them in parentheses directly behind the element's name. You can assign an attribute any printable expression you want.
To write boolean attributes omit the value or set it to a boolean:
Attributes can even span multiple lines.
Classes and IDs
Classes and IDs, being incredibly common, even get their own short form.
Corgis are smart doggos! Corgi will combine multiple class attributes and short forms into a single class
attribute. This does not work for other attributes.
The &
-Operator
&
-OperatorOne of the features that sets corgi apart from other template engines is its &
-operator.
You can use it to add an attribute to the element from its body. This is super useful, if your attribute is conditional:
You can only place the &
-operator before you write text or another element to the element's body. If you don't, the compiler will complain:
The above won't compile:
The div
Shorthand
div
Shorthanddiv
s are incredibly common. Therefore, as long as your div has at least one class or an id, you can write .foo
or #bar
to produce a div
.
Last updated
Was this helpful?