Comparing version 0.7.1 to 0.7.2
@@ -37,2 +37,3 @@ "use strict"; | ||
const sass_1 = __importDefault(require("sass")); | ||
const blockHelpers = __importStar(require("../blockHelpers")); | ||
const configuration_1 = __importDefault(require("../configuration")); | ||
@@ -58,11 +59,12 @@ const Actions = __importStar(require("../entities/actions")); | ||
registerMissingPropertyHelper(); | ||
registerIfEqHelper(); | ||
registerIfNeHelper(); | ||
registerIfGtHelper(); | ||
registerIfGeHelper(); | ||
registerIfLtHelper(); | ||
registerIfLeHelper(); | ||
registerIfAndHelper(); | ||
registerIfOrHelper(); | ||
registerIfXorHelper(); | ||
// Block helpers registration | ||
blockHelpers.if_eq(); | ||
blockHelpers.if_ne(); | ||
blockHelpers.if_gt(); | ||
blockHelpers.if_ge(); | ||
blockHelpers.if_lt(); | ||
blockHelpers.if_le(); | ||
blockHelpers.if_and(); | ||
blockHelpers.if_or(); | ||
blockHelpers.if_xor(); | ||
injectGlobalsToHelpers(globals); | ||
@@ -278,177 +280,2 @@ clearDistributionDirectoryIfNeeded(); | ||
} | ||
/** IF EQUALS block helper | ||
* @example | ||
* {{#if_eq var 'value' }} | ||
* var === 'value' | ||
* {{else}} | ||
* var !== 'value' | ||
* {{/if_eq}} | ||
*/ | ||
function registerIfEqHelper() { | ||
handlebars_1.default.registerHelper('if_eq', function (a, b, options) { | ||
if (a == b) { | ||
return options.fn(this); | ||
} | ||
else { | ||
return options.inverse(this); | ||
} | ||
}); | ||
} | ||
/** IF NOT EQUALS block helper | ||
* @example | ||
* {{#if_ne var 'value' }} | ||
* var !== 'value' | ||
* {{else}} | ||
* var === 'value' | ||
* {{/if_ne}} | ||
*/ | ||
function registerIfNeHelper() { | ||
handlebars_1.default.registerHelper('if_ne', function (a, b, options) { | ||
if (a != b) { | ||
return options.fn(this); | ||
} | ||
else { | ||
return options.inverse(this); | ||
} | ||
}); | ||
} | ||
/** IF GREATER THAN block helper | ||
* @example | ||
* {{#if_gt var N }} | ||
* var > N | ||
* {{else}} | ||
* var < N | ||
* {{/if_gt}} | ||
*/ | ||
function registerIfGtHelper() { | ||
handlebars_1.default.registerHelper('if_gt', function (a, b, options) { | ||
if (a > b) { | ||
return options.fn(this); | ||
} | ||
else { | ||
return options.inverse(this); | ||
} | ||
}); | ||
} | ||
/** IF GREATER OR EQUAL TO block helper | ||
* @example | ||
* {{#if_ge var N }} | ||
* var >= N | ||
* {{else}} | ||
* var <= N | ||
* {{/if_ge}} | ||
*/ | ||
function registerIfGeHelper() { | ||
handlebars_1.default.registerHelper('if_ge', function (a, b, options) { | ||
if (a >= b) { | ||
return options.fn(this); | ||
} | ||
else { | ||
return options.inverse(this); | ||
} | ||
}); | ||
} | ||
/** IF LESS THAN block helper | ||
* @example | ||
* {{#if_lt var N }} | ||
* var < N | ||
* {{else}} | ||
* var > N | ||
* {{/if_lt}} | ||
*/ | ||
function registerIfLtHelper() { | ||
handlebars_1.default.registerHelper('if_lt', function (a, b, options) { | ||
if (a < b) { | ||
return options.fn(this); | ||
} | ||
else { | ||
return options.inverse(this); | ||
} | ||
}); | ||
} | ||
/** IF LESS OR EQUAL TO block helper | ||
* @example | ||
* {{#if_le var N }} | ||
* var <= N | ||
* {{else}} | ||
* var >= N | ||
* {{/if_le}} | ||
*/ | ||
function registerIfLeHelper() { | ||
handlebars_1.default.registerHelper('if_le', function (a, b, options) { | ||
if (a <= b) { | ||
return options.fn(this); | ||
} | ||
else { | ||
return options.inverse(this); | ||
} | ||
}); | ||
} | ||
/** IF AND block helper | ||
* @example | ||
* {{#if_and a b c ... }} | ||
* a && b && c ... === true | ||
* {{else}} | ||
* a && b && c ... === false | ||
* {{/if_and}} | ||
*/ | ||
function registerIfAndHelper() { | ||
handlebars_1.default.registerHelper('if_and', function (...args) { | ||
if (args.length <= 2) { | ||
throw new Error('Block helper #if_and requires 2 or more arguments: {{#if_and a b ... }} {{/if_and}}'); | ||
} | ||
const options = args[args.length - 1]; | ||
const resultBooleanValue = args.slice(0, args.length - 1).every((arg) => arg); | ||
if (resultBooleanValue) { | ||
return options.fn(this); | ||
} | ||
else { | ||
return options.inverse(this); | ||
} | ||
}); | ||
} | ||
/** IF OR block helper | ||
* @example | ||
* {{#if_or a b c ... }} | ||
* a || b || c ... === true | ||
* {{else}} | ||
* a || b || c ... === false | ||
* {{/if_or}} | ||
*/ | ||
function registerIfOrHelper() { | ||
handlebars_1.default.registerHelper('if_or', function (...args) { | ||
if (args.length <= 2) { | ||
throw new Error('Block helper #if_or requires 2 or more arguments: {{#if_or a b ... }} {{/if_or}}'); | ||
} | ||
const options = args[args.length - 1]; | ||
const resultBooleanValue = args.slice(0, args.length - 1).some((arg) => arg); | ||
if (resultBooleanValue) { | ||
return options.fn(this); | ||
} | ||
else { | ||
return options.inverse(this); | ||
} | ||
}); | ||
} | ||
/** IF XOR block helper | ||
* @example | ||
* {{#if_xor a b c ... }} | ||
* There is at least 1 TRUE value and 1 FALSE value | ||
* {{else}} | ||
* All values are TRUE or all values are FALSE | ||
* {{/if_xor}} | ||
*/ | ||
function registerIfXorHelper() { | ||
handlebars_1.default.registerHelper('if_xor', function (...args) { | ||
if (args.length <= 2) { | ||
throw new Error('Block helper #if_xor requires 2 or more arguments: {{#if_xor a b ... }} {{/if_xor}}'); | ||
} | ||
const options = args[args.length - 1]; | ||
const values = args.slice(0, args.length - 1); | ||
if (values.every((value) => value) || values.every((value) => !value)) { | ||
return options.inverse(this); | ||
} | ||
return options.fn(this); | ||
}); | ||
} | ||
function scanSourceFiles() { | ||
@@ -455,0 +282,0 @@ const allSourceFiles = filesystem.scanFiles(configuration_1.default.getSourceDirectoryPath(), false, true, true); |
{ | ||
"name": "symply", | ||
"version": "0.7.1", | ||
"version": "0.7.2", | ||
"description": "A simple static site generator.", | ||
@@ -5,0 +5,0 @@ "author": "Oleg Legun <oleg.legun@gmail.com>", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
201427
31
1808