Skip to content

Commit

Permalink
style attribute require ";", so the delimiter for the attributes chan…
Browse files Browse the repository at this point in the history
…ged from ";" to "#"
  • Loading branch information
StefanoBalocco committed Jan 29, 2022
1 parent a5fb256 commit 6a06825
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ The engine support the following data-attribute (the order isn't casual, is the
* data-tdal-repeat="repeat-variabile path-expression"
* data-tdal-content="path-expression-string-allowed" OR
* data-tdal-replace="path-expression-string-allowed"
* data-tdal-attributes="attribute path-expression-string-allowed[; attributes path-expression-string-allowed]"
* data-tdal-attributes="attribute path-expression-string-allowed[#attributes path-expression-string-allowed]"
* data-tdal-omittag="path-expression-boolean-mod-allowed"

I plan the implement the jTDAL equivalent of the TAL's METAL (partials in mustache) in a future update.
Expand Down Expand Up @@ -90,7 +90,7 @@ Replace the tag and its content with the result of the path-expression. Mutually
If the result of the path expression is "false", the tag and its contents will be removed (like a false data-tdal-condition). If is "true", the default content will be kept.

### Attribute
data-tdal-attributes="href link | STRING:https://www.example.org/{page}; class STRING:link-color-blue"
data-tdal-attributes="href link | STRING:https://www.example.org/{page}#class STRING:link-color-blue"

Add an attribute or replace the content of an attribute with the result of the path expression. If the expression value is "true" current attribute content will be kept.

Expand Down
4 changes: 2 additions & 2 deletions jTDAL.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var jTDAL;
(function (jTDAL) {
const regexpPatternPath = '(?:[\\w-\\/]*[\\w](?:[\\s]*\\|[\\s]*[\\w-\\/]*[\\w])*)';
const regexpPatternPathAllowedBoolean = '(?:(?:!)?[\\w-\\/]*[\\w](?:[\\s]*\\|[\\s]*[\\w-\\/]*[\\w])*)';
const regexpPatternExpressionAllowedBoolean = '(STRING:[^;]+|' + regexpPatternPathAllowedBoolean + ')';
const regexpPatternExpressionAllowedBoolean = '(STRING:[^#]+|' + regexpPatternPathAllowedBoolean + ')';
const keywords = ['condition', 'repeat', 'content', 'replace', 'attributes', 'omittag'];
const regexp = {
'tagWithTDAL': new RegExp('<((?:\\w+:)?\\w+)(\\s+[^<>]+?)??\\s+data-tdal-(?:' + keywords.join('|') +
Expand All @@ -16,7 +16,7 @@ var jTDAL;
'condition': new RegExp('^[\\s]*(' + regexpPatternExpressionAllowedBoolean + ')[\\s]*$'),
'repeat': new RegExp('^[\\s]*([\\w-]+?)[\\s]+(' + regexpPatternPath + ')[\\s]*$'),
'content': new RegExp('^[\\s]*(?:(text|structure)[\\s]+)?(' + regexpPatternExpressionAllowedBoolean + ')[\\s]*$'),
'attributes': new RegExp('[\\s]*(?:(?:([\\w-]+?)[\\s]+(' + regexpPatternExpressionAllowedBoolean + ')[\\s]*)(?:;[\\s]*|$))', 'g'),
'attributes': new RegExp('[\\s]*(?:(?:([\\w-]+?)[\\s]+(' + regexpPatternExpressionAllowedBoolean + ')[\\s]*)(?:#[\\s]*|$))', 'g'),
'attributesTDAL': new RegExp('\\s*(data-tdal-[\\w-]+)=(?:([\'"])(.*?)\\2|([^>\\s\'"]+))', 'gi')
};
const HTML5VoidElements = ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', 'track', 'wbr'];
Expand Down
2 changes: 1 addition & 1 deletion jTDAL.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions jTDAL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ namespace jTDAL {
const regexpPatternPath: string = '(?:[\\w-\\/]*[\\w](?:[\\s]*\\|[\\s]*[\\w-\\/]*[\\w])*)';
const regexpPatternPathAllowedBoolean: string = '(?:(?:!)?[\\w-\\/]*[\\w](?:[\\s]*\\|[\\s]*[\\w-\\/]*[\\w])*)';
//const regexpPatternExpression: string = '(STRING:[^;]+|' + regexpPatternPathAllowedBoolean + ')';
const regexpPatternExpressionAllowedBoolean: string = '(STRING:[^;]+|' + regexpPatternPathAllowedBoolean + ')';
const regexpPatternExpressionAllowedBoolean: string = '(STRING:[^#]+|' + regexpPatternPathAllowedBoolean + ')';
const keywords: string[] = [ 'condition', 'repeat', 'content', 'replace', 'attributes', 'omittag' ];
const regexp: { [ key: string ]: RegExp } = {
'tagWithTDAL': new RegExp( '<((?:\\w+:)?\\w+)(\\s+[^<>]+?)??\\s+data-tdal-(?:' + keywords.join( '|' ) +
Expand All @@ -16,7 +16,7 @@ namespace jTDAL {
'condition': new RegExp( '^[\\s]*(' + regexpPatternExpressionAllowedBoolean + ')[\\s]*$' ),
'repeat': new RegExp( '^[\\s]*([\\w-]+?)[\\s]+(' + regexpPatternPath + ')[\\s]*$' ),
'content': new RegExp( '^[\\s]*(?:(text|structure)[\\s]+)?(' + regexpPatternExpressionAllowedBoolean + ')[\\s]*$' ),
'attributes': new RegExp( '[\\s]*(?:(?:([\\w-]+?)[\\s]+(' + regexpPatternExpressionAllowedBoolean + ')[\\s]*)(?:;[\\s]*|$))', 'g' ),
'attributes': new RegExp( '[\\s]*(?:(?:([\\w-]+?)[\\s]+(' + regexpPatternExpressionAllowedBoolean + ')[\\s]*)(?:#[\\s]*|$))', 'g' ),
'attributesTDAL': new RegExp( '\\s*(data-tdal-[\\w-]+)=(?:([\'"])(.*?)\\2|([^>\\s\'"]+))', 'gi' )
};
// {\?((?:[\w-\/]*[\w](?:[\s]*\|[\s]*[\w-\/]*[\w])*))}(.*?){\?(?:[\w-\/]*[\w](?:[\s]*\|[\s]*[\w-\/]*[\w])*)}
Expand Down

0 comments on commit 6a06825

Please sign in to comment.