Skip to content

Instantly share code, notes, and snippets.

@jakubfiala
Created March 28, 2017 09:38
Show Gist options
  • Save jakubfiala/404b568797e68a430b2557ecbd215060 to your computer and use it in GitHub Desktop.
Save jakubfiala/404b568797e68a430b2557ecbd215060 to your computer and use it in GitHub Desktop.
Fractal config where resources aren't being loaded
const path = require('path');
const fractal = module.exports = require('@frctl/fractal').create();
const mandelbrot = require('@frctl/mandelbrot');
const TPLAdapter = require('./pattern-library/tpl-php-adapter.js');
// PROJECT VARS
fractal.set('project.title', 'Web Components');
fractal.set('project.version', 'v1.0');
fractal.set('project.author', 'Jakub Fiala');
// COMPONENT SETTINGS
fractal.components.engine(TPLAdapter);
fractal.components.set('default.status', 'wip');
fractal.components.set('path', path.join(__dirname, 'pattern-library/components'));
fractal.components.set('ext', '.tpl.php');
// DOCS SETTINGS
fractal.docs.set('path', path.join(__dirname, 'pattern-library', 'docs'));
// BUILD SETTINGS
fractal.web.set('builder.dest', path.join(__dirname, 'pattern-library', 'build'));
fractal.web.set('static.path', path.join(__dirname, 'assets'));
fractal.web.set('static.mount', 'assets');
const customTheme = mandelbrot({
favicon: path.join(__dirname, 'favicon.ico'),
nav: [ "docs", "components" ],
panels: ["html", "view", "context", "resources", "info", "notes"],
skin: 'navy',
styles: ['default', '/theme/custom.css']
});
customTheme.addStatic(path.join(__dirname, 'pattern-library/theme'), '/theme');
fractal.web.theme(customTheme);
'use strict';
const Adapter = require('@frctl/fractal').Adapter;
const tpl = require('tpl-php');
/**
* A Fractal adapter to render tpl.php files
*
* @class TPLAdapter (TPLAdapter)
*/
class TPLAdapter extends Adapter {
render(tplPath, str, context, meta) {
return new Promise((res, rej) => {
tpl(tplPath, context)
.then(output => res(output))
.catch(err => rej(err));
});
}
}
module.exports = function() {
return {
register(source, app) {
return new TPLAdapter(tpl, source);
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment