Skip to content

Commit

Permalink
enhancement: The editor is able to detect abe type=data in each state…
Browse files Browse the repository at this point in the history
…ments
  • Loading branch information
gregorybesson committed Jan 1, 2017
1 parent 1286b0c commit 6ce435a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/server/controllers/editor.js
Expand Up @@ -114,7 +114,7 @@ function insertAbeEach (obj, text, json, util, arrayBlock) {

function each(text, json, util, arrayBlock) {
let pattEach = /(\{\{#each (\r|\t|\n|.)*?\/each\}\})/g
let patt = /abe [^{{}}]+?(?=\}})/g
let patt = /{{(abe .*?["']) ?}}/g
var textEach, match

while (textEach = pattEach.exec(text)) {
Expand Down Expand Up @@ -158,6 +158,10 @@ function each(text, json, util, arrayBlock) {
}

function addSource(text, json, util) {
// removing each blocks potentially containing abe data type
let pattEach = /(\{\{#each (\r|\t|\n|.)*?\/each\}\})/g
text = text.replace(pattEach, '')

var listReg = /({{abe.*type=[\'|\"]data.*}})/g
var match

Expand Down Expand Up @@ -251,8 +255,6 @@ export function editor(text, json, documentLink, precontrib = false) {
.then(() => {
addSource(text, json, util)

text = cmsData.source.removeDataList(text)

if (!precontrib) {
text = cmsTemplates.template.setAbeSlugDefaultValueIfDoesntExist(text)
text = cmsTemplates.template.setAbePrecontribDefaultValueIfDoesntExist(text)
Expand All @@ -262,6 +264,7 @@ export function editor(text, json, documentLink, precontrib = false) {
arrayBlock = []
each(text, json, util, arrayBlock)

text = cmsData.source.removeDataList(text)
if(typeof json.abe_meta !== 'undefined' && json.abe_meta !== null) {
var links = json.abe_meta.link.split('/')
var link = links.pop()
Expand Down

0 comments on commit 6ce435a

Please sign in to comment.