Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@semantic-ui/templating

Package Overview
Dependencies
Maintainers
0
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@semantic-ui/templating - npm Package Compare versions

Comparing version 0.0.29 to 0.0.30

12

package.json

@@ -8,9 +8,9 @@ {

"dependencies": {
"@semantic-ui/component": "^0.0.29",
"@semantic-ui/query": "^0.0.29",
"@semantic-ui/reactivity": "^0.0.29",
"@semantic-ui/templating": "^0.0.29",
"@semantic-ui/utils": "^0.0.29"
"@semantic-ui/component": "^0.0.30",
"@semantic-ui/query": "^0.0.30",
"@semantic-ui/reactivity": "^0.0.30",
"@semantic-ui/templating": "^0.0.30",
"@semantic-ui/utils": "^0.0.30"
},
"version": "0.0.29"
"version": "0.0.30"
}

@@ -9,2 +9,3 @@ import { each, isString, last } from '@semantic-ui/utils';

this.templateString = templateString || '';
this.snippets = {};
}

@@ -17,4 +18,6 @@

EACH: /^{{\s*#each\s+/,
SNIPPET: /^{{\s*#snippet\s+/,
CLOSE_IF: /^{{\s*\/(if)\s*/,
CLOSE_EACH: /^{{\s*\/(each)\s*/,
CLOSE_SNIPPET: /^{{\s*\/(snippet)\s*/,
SLOT: /^{{>\s*slot\s*/,

@@ -31,6 +34,7 @@ TEMPLATE: /^{{>\s*/,

static templateRegExp = {
VERBOSE_KEYWORD: /^template\W/g,
VERBOSE_KEYWORD: /^(template|snippet)\W/g,
VERBOSE_PROPERTIES: /(\w+)\s*=\s*(((?!\w+\s*=).)+)/gms,
STANDARD: /(\w+)\s*=\s*((?:(?!\n|$|\w+\s*=).)+)/g,
DATA_OBJECT: /(\w+)\s*:\s*([^,}]+)/g, // parses { one: 'two' }
SINGLE_QUOTES: /\'/g,
};

@@ -51,3 +55,3 @@

// quicker to compile regexp once
// quicker to compile regExp once
const tagRegExp = TemplateCompiler.tagRegExp;

@@ -75,2 +79,3 @@

let contentStack = []; // Track the current content target stack
let currentSnippet = null; // Track the current snippet being rendered

@@ -84,2 +89,3 @@ while (!scanner.isEOF()) {

if (tag) {

@@ -140,2 +146,38 @@ let newNode = {

case 'CLOSE_IF':
if (conditionStack.length == 0) {
scanner.returnTo(tagRegExp.CLOSE_IF);
scanner.fatal('{{/if}} close tag found without open if tag');
}
stack.pop();
contentStack.pop();
conditionStack.pop();
contentBranch = last(contentStack); // Reset current branch
break;
case 'SNIPPET':
newNode = {
...newNode,
type: 'snippet',
name: tag.content,
content: [],
};
this.snippets[tag.content] = newNode;
contentTarget.push(newNode);
conditionStack.push(newNode);
contentStack.push(newNode);
contentBranch = newNode;
break;
case 'CLOSE_SNIPPET':
if (conditionStack.length == 0) {
scanner.returnTo(tagRegExp.CLOSE_IF);
scanner.fatal('{{/snippet}} close tag found without open if tag');
}
stack.pop();
contentStack.pop();
conditionStack.pop();
contentBranch = last(contentStack); // Reset current branch
break;
case 'HTML_EXPRESSION':

@@ -180,13 +222,2 @@ newNode = {

case 'CLOSE_IF':
if (conditionStack.length == 0) {
scanner.returnTo(tagRegExp.CLOSE_IF);
scanner.fatal('{{/if}} close tag found without open if tag');
}
stack.pop();
contentStack.pop();
conditionStack.pop();
contentBranch = last(contentStack); // Reset current branch
break;
case 'EACH':

@@ -234,3 +265,2 @@ const contentParts = tag.content.split(' in ');

}
return ast;

@@ -251,3 +281,2 @@ }

}
parseTemplateString(expression = '') {

@@ -257,3 +286,5 @@ // quicker to compile regexp once

let templateInfo = {};
if (regExp.VERBOSE_KEYWORD.exec(expression)) {
regExp.VERBOSE_KEYWORD.lastIndex = 0;
if (regExp.VERBOSE_KEYWORD.test(expression)) {
// verbose notation {{> template name=templateName reactiveData={one: 'one', two: 'two'} }}

@@ -284,7 +315,7 @@ const matches = [...expression.matchAll(regExp.VERBOSE_PROPERTIES)];

static getObjectFromString(objectString = '') {
const regexp = TemplateCompiler.templateRegExp.DATA_OBJECT;
const regExp = TemplateCompiler.templateRegExp.DATA_OBJECT;
const obj = {};
let match;
let isObject = false;
while ((match = regexp.exec(objectString)) !== null) {
while ((match = regExp.exec(objectString)) !== null) {
isObject = true;

@@ -291,0 +322,0 @@ obj[match[1]] = match[2].trim();

@@ -39,5 +39,23 @@ import { Reaction } from '@semantic-ui/reactivity';

},
classes(array = []) {
return array.join(' ') + ' ';
join(array = [], delimiter = ' ', spaceAfter = false) {
if(array.length == 0) {
return;
}
const value = array.join(delimiter).trim();
return (spaceAfter)
? `${value} `
: value
;
},
classes(classes, spaceAfter = true) {
return TemplateHelpers.join(classes, ' ', true);
},
joinComma(array = [], oxford = false, quotes = false) {
return joinWords(array, {
separator: ', ',
lastSeparator: ' and ',
oxford: oxford,
quotes: quotes,
});
},
classIf(expr, trueClass = '', falseClass = '') {

@@ -44,0 +62,0 @@ let val = expr ? trueClass : falseClass;

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc