var blinky = (content) => span(content).class('blink').class('pink');
var sparkles = blinky(sparkles);
```
Element helpers allow adding class or id attributers to html elements, which Markdown syntax doesn't support. They provide a native (Javascript or Coffeescript) syntax, so that for (some users) they may be more readable than writing HTML elements by hand. And they come with shorthand for defining Raconteur-style action links:
```javascript
a("foo").replacer("bar")
// Stringifies as <aclass="replacer"href="./_replacer_bar">foo</a>
```
ElementHelper objects obey the following rules:
- They are immutable (frozen).
- All of the prototype's methods return a new, modified, frozen object the new object inherits from the old one, and so it supplies all of the same methods.
- They supply a `toString()` method that generates the html tag itself, using all of their data.
Because `toString()` is the method that JavaScript itself uses to coerce Objects into Strings, for example during string interpolation/concatenation, you usually don't have to explicitly call it; merely placing an ElementHelper object inside a template string will generate the tag, and this is the most common usage when placing links inside content, writer, and action properties of situations.
```coffeescript
"#{span('foo')}" # -> "<span>foo</span>"
```
```javascript
`${span('foo')}`
'' + span('foo')
span('foo').toString() // All evaluate to "<span>foo</span>"
```
Because of this interface, it's easy to define a set of defaults which can then be modified:
Every ElementHelper object supplies the following methods. All of them return a new, modified ElementHelper which inherits from the ElementHelper that the method was called on. ElementHelpers are immutable to make this safe; otherwise, an ElementHelper could have its data changed by alterations to another ElementHelper further up its prototype chain.
Returns a new ElementHelper with the given String as an additional class. This method is *additive,* so it adds new classes to the element. To completely change the element's classes, use ElementHelper#Classes
## classes :: Array -> ElementHelper
Returns a new ElementHelper with the given Array as a list of classes. This shadows any previously defined classes. If you wanted to erase all of an element's classes, you could use `element.classes([])`.
## content :: String -> ElementHelper
Returns a new ElementHelper with the given content. "Content" here means the element's inner html, which will be parsed as inline markdown.
## id :: String -> ElementHelper
Returns a new ElementHelper with the given id. This string is then used as the value of the element's `id` attribute.
## ref :: String -> ElementHelper
Returns a new ElementHelper with the given string as its `_ref` property. This property is used as the value of the element's `href` attribute.
Aliases for `ElementHelper#ref`, for code legibility.
## once
Returns a new ElementHelper with the `once` class added to it. This class has special meaning to Undum (once links stop being hyperlinks once clicked on). This method is shorthand for `class('once')`.
## type :: String -> ElementHelper
Returns a new ElementHelper with its `_linkType` property set to the given string. This property is used to integrate with Raconteur's special link types. When the ElementHelper is stringified, the `_linkType` property is added as a class to the link, and as a prefix to its href. So a link with a type of "writer" and a ref of "foo" will be written out with `href="./_writer_foo"`; when clicked, Raconteur will look for the current situation's `writers.foo` property.
If an ElementHelper's type is `action`, it will prefix the link's ref with `./` only.
It's possible to clear an element's `_linkType_` property by setting it to `null` or an empty string: `element.type(null)`.
## writer, replacer, inserter, action
All of those methods are shorthand for defining an ElementHelper for an action link.