diff --git a/addon/helpers/substr.js b/addon/helpers/substr.js new file mode 100644 index 0000000..e69d0ce --- /dev/null +++ b/addon/helpers/substr.js @@ -0,0 +1,13 @@ +import Ember from 'ember'; + +export function substr([value, ...rest], hash) { + if (typeof value === 'string') { + let start = hash.start || 0; + let length = hash.length; + return value.substr(start, length); + } else { + return value; + } +} + +export default Ember.Helper.helper(substr); diff --git a/app/helpers/substr.js b/app/helpers/substr.js new file mode 100644 index 0000000..ac66502 --- /dev/null +++ b/app/helpers/substr.js @@ -0,0 +1 @@ +export { default, substr } from 'ember-string-helpers/helpers/substr'; diff --git a/tests/dummy/app/templates/application.hbs b/tests/dummy/app/templates/application.hbs index fd20f0d..7c2fad8 100644 --- a/tests/dummy/app/templates/application.hbs +++ b/tests/dummy/app/templates/application.hbs @@ -3,412 +3,463 @@
- ember-string-helpers
will add a collection of string helpers for you to use in your templates. These helpers will help you easily format strings in order to avoid needing a computed property.
-
+ ember-string-helpers
will add a collection of string helpers for you to use in your templates. These helpers will help you easily format strings in order to avoid needing a computed property.
+
ember install ember-string-helpers- - +
ember install ember-string-helpers+ +
- Stable - Stable version released. All additional development will be tagged as a new release. -
- - ++ Stable + Stable version released. All additional development will be tagged as a new release. +
+ +""
""
2
"."
","
false
""
"dddd, MMMM Do YYYY, h:mm a"
""
true
the string will be foncverted to lower case fisrt.false
""
""
""
replacePattern
. You can send this parameter with or without the surrounding /
. Do not include flags in the string. Use the flags
hash instead.""
""
String.prototype.replace()
native flags. If specified, flags can have any combination of the following values:
-
- null
""
""
2
"."
","
false
""
"dddd, MMMM Do YYYY, h:mm a"
""
true
the string will be foncverted to lower case fisrt.false
""
""
""
replacePattern
. You can send this parameter with or without the surrounding /
. Do not include flags in the string. Use the flags
hash instead.""
""
String.prototype.replace()
native flags. If specified, flags can have any combination of the following values:
+
+ null
""
""
""