diff --git a/README.md b/README.md index 6bfef20..4c0d54d 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ Writing any html is a valid template. This does not apply to event handlers ("on In html attributes and text, you can replace context by a javascript expression. You do this by wrapping it in {}. If this is inside an attribute, it still needs to be wrapped by quotes. In text, you can just use it. ###### Sample: -``` +```html {this.state.linkText} ``` ###### Compiled: @@ -63,7 +63,7 @@ This gives you the ability to add conditions to a sub-tree of html. If the condi ###### Sample: -``` +```html
Success!
``` ###### Compiled: @@ -83,7 +83,7 @@ define([ Repeats a node with its subtree for each item in an array. This is implemented by creating a method that is passed to a map call as a callback. It creates a real context for the iterated variable. The syntax is `rt-repeat="itemVar in arrayExpr"`. Within the scope of the element, `itemVar` will be available in javascript context, and also an `itemVarIndex` will be created to represent the index of the item. If the definition is `myNum in this.getMyNumbers()`, than there will be 2 variables in the scope: `myNum` and `myNumIndex`. This naming is used to allow nesting of repeat expression with access to all levels. ###### Sample: -``` +```html
{myNumIndex}. myNum
``` ###### Compiled: @@ -106,7 +106,7 @@ define([ This directive creates a new javascript scope. It actually creates a new method for this scope, and calls it with its current context. The syntax is `rt-scope="expr1 as var1; expr2 as var2`. This gives a convenience method to shorten stuff up in a scope and make the code more readable. It also helps to execute an expression only once in a scope instead of every chunk that needs it. ###### Sample: -``` +```html
{rptIndex}{separator} {val}
'rpt' exists here, but not 'separator' and 'val'
@@ -142,7 +142,7 @@ In order to reduce the boiler-plate code when programatically setting class name 2. You cannot use class and rt-class on the same html element ###### Sample: -``` +```html
These are logically equivalent
Reference
@@ -178,7 +178,7 @@ define([ In order to make it closer to html, we allow the settings of inline styles. In addition, this will take care of changing the styles from hyphen-style to camelCase style. If you'd like, you can still return an object from evaluation context. Please note that if you do it inline, you'll need to open single curly braces for the js context, and another for the object. Also, you'll need to use camelCase if using it that way ###### Sample: -``` +```html
These are really equivalent
Inline
@@ -212,7 +212,7 @@ define([ React event handlers accept function pointers. Therefore, when using event, you can just open an execution context and provide a pointer to a method. This would look like `onClick="{this.myClickHandler}"`. However, sometimes there's very little to do on click, or we just want to call a method with bound parameters. In that case, you can use a lambda notation, which will result in creating a react template creating a method for the handler. It does not have a performance impact, as the method is created once, and just bound to the context instead of created again. The lambda notation will look like this `onClick="(evt) => console.log(evt)"`. In this example, **evt** was the name you choose for the first argument that will be passed into your inline method. With browser events, this will most likely be the react synthetic event. However, if you expect a property that starts with **on**Something, then react-templates will treat it as an event handler. So if you have an event handler called **onBoxSelected** that will trigger an event with a row and column params, you can write `onBoxSelected="(row, col)=>this.doSomething(row,col)"`. You can use a no-param version as well `onClick="()=>console.log('just wanted to know it clicked')"` ###### Sample: -``` +```html
@@ -243,7 +243,7 @@ define([ In many cases, you'd like to use either library code, or other components within your template. In order to do so, you can define a doctype and indicate dependencies. You do so by ``. After that, you will have **depVarName** in your scope. You can import react components and use them afterwords in the template as tag names. For example ``. This will also support nesting `
child
another
`. You will then be able to find the children in **this.props.children**. ###### Sample: -``` +```html
{utils.toLower(item.name)}