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

Allow file extensions other than .swig #30

Open
wants to merge 7 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
7 changes: 6 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,9 @@ language: node_js
node_js:
- "0.10"
before_script:
- npm install -g grunt-cli
- npm install -g grunt-cli
notifications:
email:
- [email protected]
- [email protected]
- [email protected]
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ This plugin requires Grunt `~0.4.1`
If you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

```shell
npm install grunt-swig --save-dev
npm install grunt-swig-revsys --save-dev
```

One the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

```js
grunt.loadNpmTasks('grunt-swig');
grunt.loadNpmTasks('grunt-swig-revsys');
```

## The "swig" task
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "grunt-swig",
"version": "0.2.1",
"name": "grunt-swig-revsys",
"version": "0.3.0",
"description": "Static site compiler built around swig",
"repository": {
"type": "git",
Expand Down
16 changes: 10 additions & 6 deletions tasks/swig.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,19 @@ module.exports = function(grunt) {
}

this.filesSrc.forEach(function(file) {
var cwd = globalVars.cwd || "";
var relativePath = file;
file = cwd + file;
if (!grunt.file.exists(file)) {
grunt.log.warn('Source file "' + file.src + '" not found.');

grunt.log.warn('Source file "' + file + '" not found.');
return false;
} else {
var dirName = path.dirname(file).split('/'),
destPath = dirName.splice(1, dirName.length).join('/'),
outputFile = path.basename(file, '.swig'),
htmlFile = config.data.dest + '/' + destPath + '/' + outputFile + '.html',
var ext = config.data.ext;
if(!ext){ext = path.extname(file);}
var dirName = path.dirname(relativePath).split('/'),
destPath = dirName.splice(0, dirName.length).join('/'),
outputFile = path.basename(file, path.extname(file)),
htmlFile = config.data.dest + '/' + destPath + '/' + outputFile + ext,
tplVars = {},
contextVars = {};

Expand Down