Skip to content

Commit

Permalink
Added .gitignore
Browse files Browse the repository at this point in the history
Fixed, in documentation, the name of the attributes tag (data-tdal-attribute -> data-tdal-attributes)
Fixed a missing ungreedy quantifier
Added terser dependency instead of uglify-es
  • Loading branch information
StefanoBalocco committed Apr 21, 2021
1 parent 44504af commit 08221a2
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
yarn.lock
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-attribute="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 @@ -88,7 +88,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-attribute="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 @@ -280,14 +280,14 @@ var jTDAL;
let tmpValue = ParsePath(tmpTDALrules[2]);
if ("false" === tmpValue) {
if ('undefined' !== (typeof attributes[tmpTDALrules[1]])) {
current[1] = current[1].replace(new RegExp('\\s*' + tmpTDALrules[1] + '(?:=([\'"]).*\\1)?'), '');
current[1] = current[1].replace(new RegExp('\\s*' + tmpTDALrules[1] + '(?:=([\'"]).*?\\1)?'), '');
}
}
else if ("true" !== tmpValue) {
current[2] += '+(false!==(t[i]=' + tmpValue + ')&&("string"===typeof t[i]||("number"===typeof t[i]&&!isNaN(t[i])))?" ' + tmpTDALrules[1] +
'=\\""+t[i]+"\\"":(true!==t[i]?"":"';
if ('undefined' !== (typeof attributes[tmpTDALrules[1]])) {
current[1] = current[1].replace(new RegExp('\\s*' + tmpTDALrules[1] + '(?:=([\'"]).*\\1)?'), '');
current[1] = current[1].replace(new RegExp('\\s*' + tmpTDALrules[1] + '(?:=([\'"]).*?\\1)?'), '');
current[2] += tmpTDALrules[1] + '"' +
((('undefined' !== (typeof attributes[tmpTDALrules[1]][3])) && ('' != attributes[tmpTDALrules[1]][3])) ? '+"="+' +
JSON.stringify(String(attributes[tmpTDALrules[1]][2] + attributes[tmpTDALrules[1]][3] +
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 @@ -301,14 +301,14 @@ namespace jTDAL {
let tmpValue = ParsePath( tmpTDALrules[ 2 ] );
if( "false" === tmpValue ) {
if( 'undefined' !== ( typeof attributes[ tmpTDALrules[ 1 ] ] ) ) {
current[ 1 ] = current[ 1 ].replace( new RegExp( '\\s*' + tmpTDALrules[ 1 ] + '(?:=([\'"]).*\\1)?' ), '' );
current[ 1 ] = current[ 1 ].replace( new RegExp( '\\s*' + tmpTDALrules[ 1 ] + '(?:=([\'"]).*?\\1)?' ), '' );
}
}
else if( "true" !== tmpValue ) {
current[ 2 ] += '+(false!==(t[i]=' + tmpValue + ')&&("string"===typeof t[i]||("number"===typeof t[i]&&!isNaN(t[i])))?" ' + tmpTDALrules[ 1 ] +
'=\\""+t[i]+"\\"":(true!==t[i]?"":"';
if( 'undefined' !== ( typeof attributes[ tmpTDALrules[ 1 ] ] ) ) {
current[ 1 ] = current[ 1 ].replace( new RegExp( '\\s*' + tmpTDALrules[ 1 ] + '(?:=([\'"]).*\\1)?' ), '' );
current[ 1 ] = current[ 1 ].replace( new RegExp( '\\s*' + tmpTDALrules[ 1 ] + '(?:=([\'"]).*?\\1)?' ), '' );
current[ 2 ] += tmpTDALrules[ 1 ] + '"' +
( ( ( 'undefined' !== ( typeof attributes[ tmpTDALrules[ 1 ] ][ 3 ] ) ) && ( '' != attributes[ tmpTDALrules[ 1 ] ][ 3 ] ) ) ? '+"="+' +
JSON.stringify( String( attributes[ tmpTDALrules[ 1 ] ][ 2 ] + attributes[ tmpTDALrules[ 1 ] ][ 3 ] +
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
"homepage": "https://github.com/StefanoBalocco/jTDAL",
"dependencies": {},
"scripts": {
"build": "node_modules/typescript/bin/tsc && node_modules/uglify-es/bin/uglifyjs jTDAL.js -o jTDAL.min.js -m -c"
"build": "node_modules/typescript/bin/tsc && node_modules/terser/bin/terser jTDAL.js -o jTDAL.min.js -m -c --mangle-props regex=/^_/"
},
"devDependencies": {
"typescript": "4",
"uglify-es": "3"
"terser": "5",
"typescript": "4"
}
}

0 comments on commit 08221a2

Please sign in to comment.