Registers a compiler that is run before all other compilers.
A macro lets you set UJS attributes that will be compiled afterwards.
If you want default attributes for every link and form, consider customizing your navigation options.
You will sometimes find yourself setting the same combination of UJS attributes again and again:
<a href="/page1" up-layer="new modal" up-class="warning" up-animation="shake">Page 1</a>
<a href="/page1" up-layer="new modal" up-class="warning" up-animation="shake">Page 1</a>
<a href="/page1" up-layer="new modal" up-class="warning" up-animation="shake">Page 1</a>
We would much rather define a new [smooth-link]
attribute that let's us
write the same links like this:
<a href="/page1" smooth-link>Page 1</a>
<a href="/page2" smooth-link>Page 2</a>
<a href="/page3" smooth-link>Page 3</a>
We can define the [content-link]
attribute by registering a macro that
sets the [up-layer]
, [up-class]
and [up-animation]
attributes for us:
up.macro('[smooth-link]', function(link) {
link.setAttribute('up-layer', 'new modal')
link.setAttribute('up-class', 'warning')
link.setAttribute('up-animation', 'shake')
})
The selector to match.
See options for up.compiler()
.
The function to call when a matching element is inserted.
See up.compiler()
for details.