Skip to content
This repository has been archived by the owner on Jul 22, 2020. It is now read-only.

Commit

Permalink
add namespaces option support (#25)
Browse files Browse the repository at this point in the history
Allow passing twig.js namespaces
  • Loading branch information
mihkeleidast authored Jan 11, 2020
2 parents 81810e8 + 23650d5 commit d00d89a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ const twigAdapter = require('@frctl/twig')({
// default is false
strict_variables: true,

// define Twig namespaces, see https://github.com/twigjs/twig.js/wiki#namespaces
// this may break some fractal functionality, like including components via their handles and the render tag
namespaces: {
'Components': './components'
},

// register custom filters
filters: {
// usage: {{ label|capitalize }}
Expand Down
6 changes: 4 additions & 2 deletions src/adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ class TwigAdapter extends Fractal.Adapter {
name: meta.self ? `${self._config.handlePrefix}${meta.self.handle}` : tplPath,
precompiled: str,
base: self._config.base,
strict_variables: self._config.strict_variables
strict_variables: self._config.strict_variables,
namespaces: self._config.namespaces
});
resolve(template.render(context));
} catch (e) {
Expand All @@ -178,7 +179,8 @@ module.exports = function(config) {
handlePrefix: '@',
importContext: false,
base: null,
strict_variables: false
strict_variables: false,
namespaces: {}
});

return {
Expand Down

0 comments on commit d00d89a

Please sign in to comment.