From 6b683855ab921d74b6e90ce5f6ff48920e003257 Mon Sep 17 00:00:00 2001 From: Spencer Watson Date: Thu, 2 Jun 2016 08:34:42 -0700 Subject: [PATCH 1/2] Make

tags optional --- README.md | 27 +++++++++++++++++++-------- app/helpers/lorem-ipsum.js | 10 +++++++--- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 0545a0f..e357fc2 100644 --- a/README.md +++ b/README.md @@ -10,33 +10,44 @@ ember install ember-cli-lorem-ipsum # if ember-cli <= 0.2.2 ember install:addon ember-cli-lorem-ipsum - -It provides a helper that makes it easy to add dummy text. The only option that the helper accepts is **length**. -The text will be returned inside a `

` tag like this: +It provides a helper that makes it easy to add dummy text. + +### Options +Option | Value | Description +--- | --- | --- +length | Number | The length of the text to return (number of characters). *Defaut* 0 (returns the default paragraph ) +html | Boolean | Wrap the text in `

` tags. *Default* true + + +If the html option is true, the text will be returned inside a `

` tag like this:

Lorem ipsum.

+Otherwise it will return as: + + Lorem ipsum. + ## Examples #### no length {{lorem-ipsum}} - +

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

#### length 11 {{lorem-ipsum length=11}} - +

Lorem ipsum.

#### length 500 - + {{lorem-ipsum length=500}} - +

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit,.

- + ## Installation * `git clone` this repository diff --git a/app/helpers/lorem-ipsum.js b/app/helpers/lorem-ipsum.js index 7b8a75b..d4b9be4 100644 --- a/app/helpers/lorem-ipsum.js +++ b/app/helpers/lorem-ipsum.js @@ -1,6 +1,6 @@ import Ember from 'ember'; -var originalText = +var originalText = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, '+ 'sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. '+ 'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut '+ @@ -19,13 +19,13 @@ export function loremIpsum(params, hash) { text = text.substring(0, hash.length); } else { var result = '', - repeatN = hash.length / text.length; + repeatN = hash.length / text.length; for (var i = 0; i < repeatN; i++) { result += text; result += (i === repeatN-1) ? '' : '. '; } - var remainder = hash.length % text.length; + var remainder = hash.length % text.length; result += text.substring(0, remainder); text = result; } @@ -33,6 +33,10 @@ export function loremIpsum(params, hash) { text += '.'; + if (hash.html === false) { + return text; + } + return new Ember.Handlebars .SafeString('

' + text + '

'); } From a20ee365e73ecaa629e3fc50418344b38ab5beb8 Mon Sep 17 00:00:00 2001 From: Spencer Watson Date: Thu, 2 Jun 2016 15:36:19 -0700 Subject: [PATCH 2/2] Fix for tests --- app/helpers/lorem-ipsum.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/lorem-ipsum.js b/app/helpers/lorem-ipsum.js index d4b9be4..436c4bd 100644 --- a/app/helpers/lorem-ipsum.js +++ b/app/helpers/lorem-ipsum.js @@ -33,7 +33,7 @@ export function loremIpsum(params, hash) { text += '.'; - if (hash.html === false) { + if (hash && hash.html === false) { return text; }