From cafeae1c20a78eade340d93c3b3c4631e828a26a Mon Sep 17 00:00:00 2001 From: mdunisch Date: Sun, 17 Aug 2014 18:36:51 +0200 Subject: [PATCH] Check out 8+9 for npm publish --- exercises/8_start_templating/exercise.js | 32 ----- exercises/8_start_templating/problem.md | 55 --------- .../8_start_templating/solution/solution.js | 10 -- exercises/9_todo_template/exercise.js | 93 -------------- exercises/9_todo_template/problem.md | 114 ------------------ .../9_todo_template/solution/solution.js | 42 ------- exercises/menu.json | 4 +- package.json | 2 +- 8 files changed, 2 insertions(+), 350 deletions(-) delete mode 100644 exercises/8_start_templating/exercise.js delete mode 100644 exercises/8_start_templating/problem.md delete mode 100644 exercises/8_start_templating/solution/solution.js delete mode 100644 exercises/9_todo_template/exercise.js delete mode 100644 exercises/9_todo_template/problem.md delete mode 100644 exercises/9_todo_template/solution/solution.js diff --git a/exercises/8_start_templating/exercise.js b/exercises/8_start_templating/exercise.js deleted file mode 100644 index b651204..0000000 --- a/exercises/8_start_templating/exercise.js +++ /dev/null @@ -1,32 +0,0 @@ -'use strict'; - -var verify = require("../../lib/verify.js"); -var _ = require("lodash"); - -var run = { - - json: { - name: "Tom", - login: [ - 1407574431, 140753421, 140715429 - ] - }, - expect: "Hello Tom (logins: 3)" -}; - - -var testing = { - 'Checking with standard dataset...': { - input: run.json, - shouldbe: run.expect - }, - 'Checking without logins': { - input: { - name: "Tom", - login: [] - }, - shouldbe: "Hello Tom (logins: 0)" - } -}; - -module.exports = verify(testing,run); diff --git a/exercises/8_start_templating/problem.md b/exercises/8_start_templating/problem.md deleted file mode 100644 index 04ba84c..0000000 --- a/exercises/8_start_templating/problem.md +++ /dev/null @@ -1,55 +0,0 @@ -# Start templating # -Do you remember the **Utilities Functions** I told you about a few -exercises before? Now it's time for them: -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. - -```js -_.template(text, data) -``` -`template` uses your `text`-var as a template and returns a interpolated -text with your `data`. -In your template you can use `<%= VARNAME %>` to print a variable. - -#### Example #### -```js -_.template('<%= value %>', { value: 'attention' }); - -// 'attention' - -``` -* * * -## Your Mission ## -Just to get started simple 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 -function should return a String like this: - -``` -Hello Foo (logins: 2) -``` - -#### Template #### -All of your solutions should follow this template: -```js -// include the Lo-Dash library -var _ = require("lodash"); - -var worker = function(/* arguments */) { - // do work; return stuff -}; - -// export the worker function as a nodejs module -module.exports = worker; -``` -**lololodash** will call your function and test it with different arguments. diff --git a/exercises/8_start_templating/solution/solution.js b/exercises/8_start_templating/solution/solution.js deleted file mode 100644 index becfacf..0000000 --- a/exercises/8_start_templating/solution/solution.js +++ /dev/null @@ -1,10 +0,0 @@ -var _ = require("lodash"); - -var template = function(inputvar) { - - var mytemplate= "Hello <%= name %> (logins: <%= login.length %>)"; - - return _.template(mytemplate, inputvar); -}; - -module.exports = template; \ No newline at end of file diff --git a/exercises/9_todo_template/exercise.js b/exercises/9_todo_template/exercise.js deleted file mode 100644 index ef87801..0000000 --- a/exercises/9_todo_template/exercise.js +++ /dev/null @@ -1,93 +0,0 @@ -'use strict'; - -var verify = require("../../lib/verify.js"); -var _ = require("lodash"); -var moment = require("moment"); - -var run = { - - json: { - "Tom": [ - { - todo: "Clean kitchen", - date: moment().add(10, 'days') - }, - { - todo: "Lean Lo-Dash", - date: moment().add(1, 'days') - }, - { - todo: "Become a Lo-Dash master", - date: moment().add(3, 'days') - } - ], - "Tim": [ - { - todo: "Contibute to an Open-Sorce-Project", - date: moment().add(2, 'days') - } - ] - }, - expect: "" -}; - - -var testing = { - 'Checking with standard dataset...': { - input: run.json, - shouldbe: run.expect - }, - 'Checking without elements': { - input: {}, - shouldbe: "" - }, - 'Checking without todos': { - input: { - Martin: [], - Tina: [], - Nina: [] - }, - shouldbe: "" - }, - 'Checking sorting': { - input: { - Martin: [ - { - todo: "1", - date: moment().add(3, 'days') - }, - { - todo: "2", - date: moment().add(2, 'days') - }, - { - todo: "3", - date: moment().add(1, 'days') - }, - { - todo: "4", - date: moment().add(10, 'days') - } - ] - }, - shouldbe: "" - }, - 'Checking timecalculation': { - input: { - Martin: [ - { - todo: "1", - date: moment().add(2, 'days').add(1, 'hours') - }, - { - todo: "1", - date: moment().add(1, 'days').add(23, 'hours') - } - - ] - }, - shouldbe: "" - } -}; - -module.exports = verify(testing,run); diff --git a/exercises/9_todo_template/problem.md b/exercises/9_todo_template/problem.md deleted file mode 100644 index 8b22432..0000000 --- a/exercises/9_todo_template/problem.md +++ /dev/null @@ -1,114 +0,0 @@ -# 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 -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 - -#### Example #### -```js -var mytemplate = '<% _.forEach(data, function(item){ %>' + - '
  • <%= item %>
  • ' + -'<% }); %>'; -_.template(mytemplate, {data: [1, 2, 3]}); - -/* -
  • 1
  • -
  • 2
  • -
  • 3
  • -*/ -``` -So you can write templates without learning a template-syntax only use -Javascript - isn't that awesome? - - -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 -template as local variables. - -#### Example #### -```js -var ucfirst = function (str) { - var f = str.charAt(0).toUpperCase(); - return f + str.substr(1); -}; - -_.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 -[Lo-Dash docs](http://lodash.com/docs#template). - - -* * * -## Your Mission ## -We have a JSON of different To-do's: - -```js -{ "Tom": [ - { - "todo": "Clean kitchen", - "date": "2014-08-19T12:13:20.207Z" - }, - { - "todo": "Lean Lo-Dash", - "date": "2014-08-10T12:13:20.210Z" - }, - { - "todo": "Become a Lo-Dash master", - "date": "2014-08-12T12:13:20.210Z" - } - ], - "Tim": [ - { - "todo": "Contibute to an Open-Sorce-Project", - "date": "2014-08-11T12:13:20.210Z" - } - ] -} -``` -We want to create a simple nested `