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..436c4bd 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 && hash.html === false) { + return text; + } + return new Ember.Handlebars .SafeString('

' + text + '

'); }