Skip to content

Commit

Permalink
bug: source attr
Browse files Browse the repository at this point in the history
when using for example ["red", "green", "blue"]
  • Loading branch information
nicolaslabbe committed Dec 1, 2016
1 parent 77d5c46 commit b4df8f2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
16 changes: 10 additions & 6 deletions src/cli/cms/editor/handlebars/sourceAttr.js
Expand Up @@ -60,12 +60,16 @@ export function get(obj, path) {
* @return {string} the string with values
*/
export function prepareDisplay(obj, str) {
var keys = getKeys(str)
Array.prototype.forEach.call(keys, (key) => {
var val = get(obj, key)
var pattern = new RegExp('{{'+key+'}}|'+key)
str = str.replace(pattern, val)
})
if (typeof obj === 'string') {
return obj
}else {
var keys = getKeys(str)
Array.prototype.forEach.call(keys, (key) => {
var val = get(obj, key)
var pattern = new RegExp('{{'+key+'}}|'+key)
str = str.replace(pattern, val)
})
}

return str
}
Expand Down
16 changes: 10 additions & 6 deletions src/server/public/scripts/modules/EditorAutocomplete.js
Expand Up @@ -252,12 +252,16 @@ export default class EditorAutocomplete {
* @return {string} the string with values
*/
_prepareDisplay(obj, str) {
var keys = this._getKeys(str)
Array.prototype.forEach.call(keys, (key) => {
var val = this._get(obj, key)
var pattern = new RegExp('{{'+key+'}}|'+key)
str = str.replace(pattern, val)
})
if (typeof obj === 'string') {
str = obj
}else {
var keys = this._getKeys(str)
Array.prototype.forEach.call(keys, (key) => {
var val = this._get(obj, key)
var pattern = new RegExp('{{'+key+'}}|'+key)
str = str.replace(pattern, val)
})
}

return str
}
Expand Down

0 comments on commit b4df8f2

Please sign in to comment.