Skip to content

Commit 7e6ae9d

Browse files
committed
Update the template view
1 parent 60a7e2d commit 7e6ae9d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -700,12 +700,13 @@ Few sample AngularJS expressions are:
700700
701701
![Template View](./images/template-view.png "Fig. 8")
702702

703-
The dynamic page rendering is not that trivial thing. It is connected with a lot of string concatenations, manipulations and frustration. Far easier way to build your dynamic page is to write your markup and embed little expressions inside it, which are lately evaluated in given context and so compiled to the end format. In our case this format is going to be HTML (or even DOM). This is exactly what the template engines do they take given DSL, evaluate it in the appropriate context and then turns it into its end format.
703+
The dynamic page rendering is not that trivial thing. It is connected with a lot of string concatenations, manipulations and frustration. Far easier way to build your dynamic page is to write your markup and embed little expressions inside it, which are lately evaluated in given context and so the whole template is being compiled to its end format. In our case this format is going to be HTML (or even DOM). This is exactly what the template engines do - they take given DSL, evaluate it in the appropriate context and then turn it into its end format.
704704

705705
Templates are very commonly used especially in the back-end.
706706
For example, you can embed PHP code inside HTML and create a dynamic page, you can use Smarty or you can use eRuby with Ruby in order to embed Ruby code inside your static pages.
707707

708-
For JavaScript there are plenty of template engines, such as mustache.js, handlebars, etc. The templates of most of these engines are embedded inside the application as strings.
708+
For JavaScript there are plenty of template engines, such as mustache.js, handlebars, etc. Most of these engines manipulate the template as a string. The template could be located in different places - as static file, which is fetched with AJAX, as `script` embedded inside your view or even inlined into your JavaScript.
709+
709710
For example:
710711

711712
```html
@@ -717,7 +718,7 @@ For example:
717718
</script>
718719
```
719720

720-
The template engine turns this string into DOM elements by compiling it with a given context. This way all the expressions embedded in the markup are evaluated and replaced by their value.
721+
The template engine turns this string into DOM elements by compiling it within a given context. This way all the expressions embedded in the markup are evaluated and replaced by their value.
721722

722723
For example if we evaluate the template above in the context of the following object: `{ names: ['foo', 'bar', 'baz'] }`, so we will get:
723724

0 commit comments

Comments
 (0)