-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(template)!: replace simple template engine with handlebars
replaces the simple template engine with handlebars and a set of default helpers BREAKING CHANGE: Use handlebars as template engine. Place holders are now double curlies `{{ }}` resolves: #16
- Loading branch information
1 parent
6807acc
commit b20c89c
Showing
42 changed files
with
531 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
hoist=true | ||
package-lock=false | ||
lock-file=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
'use strict' | ||
|
||
module.exports = endsWith | ||
|
||
function endsWith(str, ...args) { | ||
if (typeof str !== 'string') return false | ||
return args.some((arg) => { | ||
return str.endsWith(arg) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
'use strict' | ||
|
||
module.exports = eq | ||
|
||
function eq(lh, rh) { | ||
return lh === rh | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
'use strict' | ||
|
||
module.exports = gt | ||
|
||
function gt(lh, rh) { | ||
return lh > rh | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
'use strict' | ||
|
||
module.exports = gte | ||
|
||
function gte(lh, rh) { | ||
return lh >= rh | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
'use strict' | ||
|
||
module.exports = includes | ||
|
||
function includes(input, arg, position) { | ||
if (!Array.isArray(input) && typeof input !== 'string') return false | ||
return input.includes(arg, position) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
'use strict' | ||
|
||
module.exports = { | ||
endswith: require('./endswith') | ||
, eq: require('./eq') | ||
, gt: require('./gt') | ||
, gte: require('./gte') | ||
, includes: require('./includes') | ||
, lower: require('./lower') | ||
, lt: require('./lt') | ||
, lte: require('./lte') | ||
, neq: require('./neq') | ||
, pick: require('./pick') | ||
, startswith: require('./startswith') | ||
, split: require('./split') | ||
, upper: require('./upper') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
'use strict' | ||
|
||
module.exports = lower | ||
|
||
function lower(str) { | ||
if (typeof str !== 'string') return '' | ||
return str.toLowerCase() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
'use strict' | ||
|
||
module.exports = lt | ||
|
||
function lt(lh, rh) { | ||
return lh < rh | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
'use strict' | ||
|
||
module.exports = lte | ||
|
||
function lte(lh, rh) { | ||
return lh < rh | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
'use strict' | ||
|
||
module.exports = neq | ||
|
||
function neq(lh, rh) { | ||
/* eslint-disable eqeqeq */ | ||
return lh != rh | ||
/* eslint-enable eqeqeq */ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
'use strict' | ||
|
||
module.exports = pick | ||
|
||
function pick(...args) { | ||
return args.find((value) => { | ||
/* eslint-disable no-eq-null */ | ||
if (value == null) return false | ||
/* eslint-enable no-eq-null */ | ||
if (value === '') return false | ||
return true | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
'use strict' | ||
|
||
module.exports = require('../../lang/array/to-array.js') | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
'use strict' | ||
|
||
module.exports = startsWith | ||
|
||
function startsWith(str, ...args) { | ||
if (typeof str !== 'string') return false | ||
return args.some((arg) => { | ||
return str.startsWith(arg) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
|
||
'use strict' | ||
|
||
module.exports = upper | ||
|
||
function upper(str) { | ||
if (typeof str !== 'string') return '' | ||
return str.toUpperCase() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
'use strict' | ||
|
||
const Handlebars = require('handlebars') | ||
const helpers = require('./helpers') | ||
const handlebars = Handlebars.noConflict() | ||
|
||
handlebars.registerHelper(helpers) | ||
|
||
module.exports = handlebars | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
'use strict' | ||
const object = require('../object/index.js') | ||
|
||
const handlebars = require('../../handlebars') | ||
|
||
module.exports = template | ||
|
||
function template(str) { | ||
return function interpolate(values) { | ||
if (typeof str !== 'string') return str | ||
return str.replace(/{([^{}]*)}/g, function(original, parsed) { | ||
const result = object.get(values, parsed) | ||
return typeof result === 'string' || typeof result === 'number' ? result : original | ||
}) | ||
if (typeof str !== 'string') return echo(str) | ||
return handlebars.compile(str) | ||
} | ||
|
||
function echo(input) { | ||
return () => { | ||
return input | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM debian:buster-slim | ||
COPY . /opt/app | ||
WORKDIR /opt/app | ||
RUN ls -alh | ||
CMD ["echo", "$PWD"] |
Oops, something went wrong.