Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Swig #4

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions bin/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,27 @@ module.exports = function ( program ) {
styleContent = fs.readFileSync(styleFile);

break;
case 'swig':

console.log(' Setting view template to '.white + 'Swig'.blue);

pkg.dependencies['swig'] = 'latest';
scriptTemplate = '<script src="{{site.dir.lib}}{{src}}" ></script>' + "\n";
styleTemplate = ' <link rel="stylesheet" href="{{site.dir.lib}}{{src}}">' + "\n";

data = data.replace(new RegExp('html : \'jade\'', 'g'), 'html: \'swig\'');
wrench.rmdirSyncRecursive(path + '/app/views');
wrench.copyDirSyncRecursive(__dirname + '/_src/lib/templates/views/swig', path + '/app/views/');

// UPDATE SCRIPT FILE
var scriptFile = path + '/app/views/_inc/footer.html',
scriptContent = fs.readFileSync(scriptFile);

// UPDATE STYLE FILE
var styleFile = path + '/app/views/_inc/header.html',
styleContent = fs.readFileSync(styleFile);

break;

default:

Expand Down
16 changes: 15 additions & 1 deletion bin/tesla
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var mkdirp = require('mkdirp'),
program
.version(version)
.usage('[options] [dir]')
.option('-H, --html <template>', 'set html teplating engine: ejs|hjs|jshtml}hogan|jade (default)')
.option('-H, --html <template>', 'set html teplating engine: ejs|hjs|jshtml}hogan|swig|jade (default)')
.option('-C, --css <engine>', 'add stylesheet <engine> support (less|stylus) (defaults to plain css)')
.option('-F, --force', 'force on non-empty directory')
.option('start', 'start the web server (still a bit buggy, best just just run "grunt" or "gulp" for now)')
Expand Down Expand Up @@ -62,6 +62,7 @@ if ( program.html === 'ejs' ) program.template = 'ejs'; // EJS
if ( program.html === 'hogan' ) program.template = 'hogan'; // HOGAN
if ( program.html === 'handlebars' ) program.template = 'handlebars'; // HANDLEBARS
if ( program.html === 'mustache' ) program.template = 'mustache'; // MUSTACHE
if ( program.html === 'swig' ) program.template = 'swig'; // swig


// SCAFFOLDING FOR MODELS/CONTROLLERS
Expand Down Expand Up @@ -271,6 +272,19 @@ if (program.install) {
// UPDATE STYLE FILE
var styleFile = path + '/app/views/_inc/header.mustache',
styleContent = fs.readFileSync(styleFile);
} else if ( fs.existsSync(path + '/app/views/index.html') ) {

viewType = 'swig';
scriptTemplate = '<script src="{{site.dir.lib}}{{src}}" ></script>' + "\n";
styleTemplate = ' <link rel="stylesheet" href="{{site.dir.lib}}{{src}}">' + "\n";

// UPDATE SCRIPT FILE
var scriptFile = path + '/app/views/_inc/footer.html',
scriptContent = fs.readFileSync(scriptFile);

// UPDATE STYLE FILE
var styleFile = path + '/app/views/_inc/header.html',
styleContent = fs.readFileSync(styleFile);
}


Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
],
"repository": {
"type": "git",
"url": "https://github.com/teslajs/tesla-cli"
"url": "https://github.com/captainhurst/tesla-cli"
},
"bugs": {
"url": "https://github.com/teslajs/tesla-cli/issues"
Expand Down