+8
-0
@@ -0,1 +1,9 @@ | ||
| # CONTRIBUTING | ||
| All sorts of contributions are welcome. Please help me add more helpful filters for VueJs. | ||
| ## Features | ||
| For *Enhancement* or *New feature*. | ||
| Make sure to follow the coding pattern. The contributor is also responsible for creating the docs in the README.md |
@@ -0,1 +1,13 @@ | ||
| const corpus = { | ||
| '<': '>', | ||
| '>': '<', | ||
| '[': ']', | ||
| ']': '[', | ||
| '(': ')', | ||
| ')': '(', | ||
| '{': '}', | ||
| '}': '{', | ||
| }; | ||
| const corpusRegex = /(<|>|\[|\]|\(|\)|\{|\})/g; | ||
| export default (Vue) => { | ||
@@ -10,5 +22,16 @@ Vue.filter('morph-sandwich', (value, start, end) => { | ||
| function flip (str) { | ||
| return str.replace(corpusRegex, match => corpus[match]) | ||
| .split('') | ||
| .reverse() | ||
| .join(''); | ||
| } | ||
| function sandwich(value, start, end) { | ||
| start = start || ''; | ||
| end = end || flip(start); | ||
| return `${ start }${ value }${ end }`; | ||
| } | ||
| }; | ||
| }; | ||
+1
-1
@@ -6,3 +6,3 @@ { | ||
| "name": "morphling", | ||
| "version": "0.1.7", | ||
| "version": "0.1.8", | ||
| "description": "A collection of VueJs filters.", | ||
@@ -9,0 +9,0 @@ "main": "index.js", |
+15
-5
@@ -305,2 +305,5 @@ # Mophling | ||
| If only a single argument is given, it is used to surround the sandwiched | ||
| content by matching open brackets for closed brackets, and so on. | ||
| *Syntax* | ||
@@ -313,7 +316,13 @@ | ||
| <!-- In the end! --> | ||
| <p>{{{ 'Numb' | morph-sandwich('<<< ') }}}</p> | ||
| <!-- <<< Numb >>> --> | ||
| ``` | ||
| ```javascript | ||
| const msg = this.$morphSandwich('the', 'In ', ' end!'); | ||
| console.log(msg); // In the end! | ||
| const msg1 = this.$morphSandwich('the', 'In ', ' end!'); | ||
| console.log(msg1); // In the end! | ||
| const msg2 = this.$morphSandwich('Numb', '<<< '); | ||
| console.log(msg2); // <<< Numb >>> | ||
| ``` | ||
@@ -361,7 +370,8 @@ | ||
| - Updated [morph-sandwich](#morph-sandwich) filter. | ||
| - Added [morph-replace](#morph-replace) filter. | ||
| - Added [morph-truncate](#morph-truncate) filter. | ||
| - Added [morph-placeholder](#morph-placeholder) filter. | ||
| - Added [morph-curreny](#morph-curreny) filter. | ||
| - Added [morph-placeholder](#morph-placeholder) filter. | ||
| - Added [morph-replace](#morph-replace) filter. | ||
| - Added [morph-sandwich](#morph-sandwich) filter. | ||
| - Added [morph-truncate](#morph-truncate) filter. | ||
@@ -368,0 +378,0 @@ *"When my time comes, |
47881
1.99%1605
1.26%420
2.44%