Skip to content

Commit

Permalink
Merge pull request #6 from nazrhyn/patch-1
Browse files Browse the repository at this point in the history
Revisions to exercises 8 and 9
  • Loading branch information
mdunisch committed Sep 25, 2014
2 parents 281c442 + c5bf8d4 commit c201e39
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 23 deletions.
10 changes: 5 additions & 5 deletions exercises/8_start_templating/problem.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ Let's do a little bit of templating!
* * *
## Lead the Way ##
For this mission, let me show you the `template` function.
_template() give you a simple and powerfull micro-templating with Lo-Dash.
_template() gives you access to simple and powerfull micro-templating with Lo-Dash.

```js
_.template(text, data)
```
`template` uses your `text`-var as a template and returns a interpolated
`template` uses your `text`-var as a template and returns interpolated
text with your `data`.
In your template you can use `<%= VARNAME %>` to print a variable.

Expand All @@ -23,16 +23,16 @@ _.template('<b><%= value %></b>', { value: 'attention' });
```
* * *
## Your Mission ##
Just to get started simple use the template()-function to interpolate
To get started, use the template() function to interpolate
a simple var for us:

```js
{ name: "Foo",
login: [ 1407574431, 140753421 ]
}
```
We want a simple string from you showing the name of the user and times,
the user had logged in (every timestamp represents one login). Your
We want a simple string greeting the user by name and showing the number of times
the user has logged in (every timestamp represents one login). Your
function should return a String like this:

```
Expand Down
35 changes: 17 additions & 18 deletions exercises/9_todo_template/problem.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# To-do Template #
If you finished the last exercise you would possibly think "template?
That's only another type for string-merge!". But the `template` function
If you finished the last exercise, you might think, "Template?
That's just another word for string-merge!; but, the `template` function
in Lo-Dash is very powerful.

* * *
## Going deep into template() ##
`template()` is much more. You can add any kind of javascript-code by
escaping it with <% %> If you familiar with PHP - <% %> is almost
the same as <? ?>
`template()` is much more. You can add any kind of javascript code by
escaping it with `<% %>`. If you are familiar with PHP, `<% %>` is almost
the same as `<? ?>`.

#### Example ####
```js
Expand All @@ -22,13 +22,13 @@ _.template(mytemplate, {data: [1, 2, 3]});
<li>3</li>
*/
```
So you can write templates without learning a template-syntax only use
Javascript - isn't that awesome?
You can write templates without learning a template syntax -- just use
Javascript. Isn't that awesome?


As a third parameter `template()` accepts a options-object. One of
As a third parameter, `template()` accepts a options object. One of
the options I really like and want to show you is `option.imports`.
With `options.imports` you can define an object to import into the
With `options.imports`, you can define an object to describe values to import into the
template as local variables.

#### Example ####
Expand All @@ -40,17 +40,16 @@ var ucfirst = function (str) {

_.template('Hello <%= ucfirst(foo) %>', {foo: "mike"}, { 'imports': { 'ucfirst': ucfirst } });
// Hello Mike

```

Again - awesome, or?
template() have many more options, you can read more about that on
Again, isn't that awesome?
template() has many more options; you can read more about them on
[Lo-Dash docs](http://lodash.com/docs#template).


* * *
## Your Mission ##
We have a JSON of different To-do's:
We have a JSON of different to-do's:

```js
{ "Tom": [
Expand All @@ -75,12 +74,12 @@ We have a JSON of different To-do's:
]
}
```
We want to create a simple nested `<ul><li>`-List of all the To-do-items.
But beside of creating HTML-Code we want you to do:
- Sort the To-do-items by date (from smallest to biggest)
- Add a "<b>URGENT</b> " to every `<li>` when the date is only 2 days or less from today.
We want to create a simple nested `<ul><li>` list of all the to-do items.
But, in addition to creating HTML code, we want you to:
- Sort the to-do items by date (from earliest to latest)
- Add a "<b>URGENT</b>" to every `<li>` when the date is only 2 days or fewer from today.

Your HTML you give us back should look like this:
The HTML produced should look like this:


```html
Expand Down

0 comments on commit c201e39

Please sign in to comment.