-
Notifications
You must be signed in to change notification settings - Fork 5
Selector Prototypes
padolsey edited this page Apr 3, 2013
·
6 revisions
SIML (0.3.2 onwards) supports selector prototypes, which allow you to define a custom selector with default attributes. You can reference this later in your current SIML scope. For example:
// Setup protototypes:
link = a.link[href=""][title=""]
// Actual template:
link 'A link with defaults'
link[title="override"] 'With overridden title'
link[href="/override"] 'With overridden href'
That generates:
<a class="link" href="" title="">
A link with defaults
</a>
<a class="link" href="" title="override">
With overridden title
</a>
<a class="link" href="/override" title="">
With overridden href
</a>
Re-defining a prototype in a given scope will augment it, but only for that scope. E.g.
foo = a.foo
div
foo = foo.baz
foo
foo
That would generate:
<div>
<a class="foo baz"></a>
</div>
<a class="foo"></a>