Comparing version 0.2.3 to 0.2.4
@@ -98,3 +98,3 @@ "use strict"; | ||
function getGlobalsFileNameWithoutExtension(fileName, extension) { | ||
return fileName.replace(new RegExp(extension + '$'), ''); | ||
return fileName.replace(new RegExp(`\\${extension}$`), ''); | ||
} |
@@ -71,3 +71,3 @@ "use strict"; | ||
function getHelpersFileName(fileName) { | ||
return fileName.replace(new RegExp(HELPERS_EXTENSION + '$'), ''); | ||
return fileName.replace(new RegExp(`\\${HELPERS_EXTENSION}$`), ''); | ||
} |
@@ -33,3 +33,3 @@ "use strict"; | ||
// TODO: add support for .md and .txt formats | ||
const PARTIAL_EXTENTION = '.html'; | ||
const SUPPORTED_PARTIAL_EXTENTION_LIST = ['.html', '.hbs']; | ||
function load() { | ||
@@ -51,3 +51,9 @@ /*----------------------------------------------------------------------------- | ||
const result = partials.reduce((acc, partial) => { | ||
acc[getPartialName(partial.name)] = partial.contents; | ||
const partialNameWithoutExtension = getPartialNameWithoutExtension(partial.name); | ||
if (acc[partialNameWithoutExtension] !== undefined) { | ||
logger_1.default.warning(`Detected partials with the same name "${partial.dirname}/${partialNameWithoutExtension}.*", but different extensions.`); | ||
} | ||
else { | ||
acc[partialNameWithoutExtension] = partial.contents; | ||
} | ||
return acc; | ||
@@ -73,4 +79,5 @@ }, {}); | ||
exports.load = load; | ||
function getPartialName(fileName) { | ||
return fileName.replace(new RegExp(PARTIAL_EXTENTION + '$'), ''); | ||
function getPartialNameWithoutExtension(fileName) { | ||
const re = `(${SUPPORTED_PARTIAL_EXTENTION_LIST.map((ext) => '\\' + ext).join('|')})$`; | ||
return fileName.replace(new RegExp(re), ''); | ||
} |
{ | ||
"name": "symply", | ||
"version": "0.2.3", | ||
"version": "0.2.4", | ||
"description": "A simple static site generator.", | ||
@@ -5,0 +5,0 @@ "author": "Oleg Legun <oleg.legun@gmail.com>", |
@@ -28,1 +28,16 @@ ![Logo](./assets/logo.png) | ||
## Render partial by passed path as a parameter | ||
```hbs | ||
<!-- index.html --> | ||
{{> partials/userCard iconPath='svg/icons/user-1' }} | ||
``` | ||
```hbs | ||
<!-- partials/userCard.html --> | ||
<div class="UserCard"> | ||
{{> (lookup . 'iconPath' ) }} | ||
</div> | ||
``` | ||
176349
1188
43