From 7c68da0a20dc49500a8ad6da910bca62e02f7a65 Mon Sep 17 00:00:00 2001 From: ache Date: Wed, 3 Jan 2018 07:55:02 +0100 Subject: HTML parametre implementation --- app.js | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 88 insertions(+), 3 deletions(-) diff --git a/app.js b/app.js index afc4eee..31cbdd1 100644 --- a/app.js +++ b/app.js @@ -30,19 +30,103 @@ function plugin() { if( value.charAt(index) == '\n' ) return true; + } + let indexNext = index+END.length; + let prop = {key:{}, classes:[],id:""} + let lets_eat = ""; + if( value.charAt(indexNext) == '{' ) { + indexNext++; + lets_eat="{" + + while(true) { + + var type = 0; + while(' \t\n\r\v'.indexOf(value.charAt(indexNext)) >= 0) { + lets_eat+=value.charAt(indexNext); + indexNext++; + } + if( value.charAt(indexNext) == '}' ) { + break; + } else if( value.charAt(indexNext) == '.' ) { // Classes + type = 1; + indexNext++; + lets_eat+='.' + } else if( value.charAt(indexNext) == '#' ) { // ID + type = 2; + indexNext++; + lets_eat+='#' + } else { // Key + type = 3; + } + let labelFirst = ""; + let labelSecond = ""; + + // Extract name + while( '=\t\b\r\v  }'.indexOf(value.charAt(indexNext)) < 0 ) { + labelFirst+=value.charAt(indexNext); + indexNext++; + } + + lets_eat+=labelFirst; + if( value.charAt(indexNext) == '=' ) { // Set labelSecond + indexNext++; + lets_eat+='='; + + if( value.charAt(indexNext) == '"' ) { + indexNext++; + lets_eat+='"'; + while('"}\n'.indexOf(value.charAt(indexNext)) < 0) { + labelSecond+=value.charAt(indexNext); + indexNext++; + } + lets_eat+=labelSecond; + if( value.charAt(indexNext) != '"' ) { + // Erreur + }else{ + indexNext++; + lets_eat+='"'; + } + } else if( value.charAt(indexNext) == "'" ) { + indexNext++; + lets_eat+="'"; + while("'}\n".indexOf(value.charAt(indexNext)) < 0) { + labelSecond+=value.charAt(indexNext); + indexNext++; + } + lets_eat+=labelSecond; + if( value.charAt(indexNext) !="'" ) { + // Erreur + }else{ + indexNext++; + lets_eat+="'"; + } + } else { + while(' \t\n\r\v=}'.indexOf(value.charAt(indexNext)) < 0) { + labelSecond+=value.charAt(indexNext); + indexNext++; + } + lets_eat+=labelSecond; + } + } + if( labelSecond ) + console.log("{{" + labelFirst + "=" + labelSecond + "}}"); + else + console.log("{{" + labelFirst + "}}"); } + lets_eat+="}"; + } /* istanbul ignore if - never used (yet) */ if (silent) return true; if( index < length ) - return eat(START + subvalue.slice(1) + END.slice(1) )({ - type: 'lineEdit', + return eat(START + subvalue.slice(1) + END.slice(1)+lets_eat)({ + type: 'line-input', children: [], data: { hName: 'input', hProperties: { type: 'text', - placeholder: subvalue + placeholder: subvalue.replace(/^_*/g, '').replace(/_*$/g, '') } } }); @@ -50,6 +134,7 @@ function plugin() { return true; } + inlineTokenizer.locator = locator; var Parser = this.Parser; -- cgit v1.2.3