Remake's Attributes
The core of Remake is custom HTML attributes.
They gives Remake the ability to:
Remake Attributes Overview
All of the functionality that Remake allows us to build so quickly — creating a complete Kanban app from scratch in record time — is done by only 9 custom attributes (used a total of 22 times).
If you learn only the following 9 custom attributes, you'll be able to build some pretty powerful apps with Remake!
object- This marks an element as a JSON object
- Elements nested inside this element will be nested inside the object
- For example, if you add an
arrayelement with akeyinside this element, then Remake will see the data like this:{keyName: []}
- For example, if you add an
array- This marks an element as a JSON array
- Elements nested inside this element will be nested inside the array
- For example, if you add a series of three elements inside this element that all have the
objectattribute, then Remake will see the data like this:[{}, {}, {}]
- For example, if you add a series of three elements inside this element that all have the
key:- Only elements with the
objectattribute can have this attribute - This attribute lets you name a piece of data and tell Remake where it's located
- For example, this HTML:
<div object key:name="@innerText">David</div>produces this data:{name:"David"}
- For example, this HTML:
- Only elements with the
key- If you want to nest the data of one element inside another one, use this attribute
- Whatever value you give to key will be the label that the nested has inside the parent element
- For example, this HTML:
<div object><div array key="myArray"></div></div>produces this data:{myArray:[]}
- For example, this HTML:
edit:- The easiest way to make a
key:editable - Just pass in a key name and put this on the same element as the key (or inside it) and Remake will automatically make it editable!
- For example, the data in this element will be editable:
<div object key:name="@innerText" edit:name>David</div>
- For example, the data in this element will be editable:
- The easiest way to make a
default:- If a user edits a piece of data and sets it to nothing, that
key:will be set to this matchingdefault:value instead
- If a user edits a piece of data and sets it to nothing, that
new:- Adds a new item to the page.
- The item's name must match a partial template's name or an item from a
{{#for}}loop - The item is rendered automatically by Remake and added to the nearest
arrayelement - For example, if you have a for loop like
{{#for item in items}}...then you can use<button new:item>Create new item!</button>to render a new item and add it to the list!
- The item's name must match a partial template's name or an item from a
- Adds a new item to the page.
sortable- All elements directly inside this element can be dragged and reordered
- For example:
<div array sortable><!--Elements here can be sorted--></div>.
- For example:
- All elements directly inside this element can be dragged and reordered
target:- This is a special, but important attribute. It lets you attach a
key:on higher-level element, but reference a value on a lower-level element. - If you pass the
@searchcommand into akey:attribute, then that key will look for its value inside its element until it finds a matchingtarget:element- For example, with:
<div object key:name="@search"><span target:name="@innerText">Sam</span></div>, the value of the key "name" is "Sam".
- For example, with:
- This is a special, but important attribute. It lets you attach a