Skip to content

Commit

Permalink
Broken fork out into own repo
Browse files Browse the repository at this point in the history
  • Loading branch information
MNZT committed Nov 17, 2015
0 parents commit d623106
Show file tree
Hide file tree
Showing 5 changed files with 160 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules/
static/
test.js
.travis.yml
65 changes: 65 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# **diet-jade**
Jade template engine plugin for [diet][2] based on [Jade][1]. Support for sending data to view through `$.data.PARAM` and displayed via `#{PARAM}`.

## **Learn about Jade**:
Learn how to use it at the engine's website:
- **Website:** [http://jade-lang.com/](http://jade-lang.com/)

## **Install**

```
npm install diet-jade
```

[![NPM](https://nodei.co/npm/diet-jade.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/diet-jade/)

## **Example Usage**
**index.js**

```js
// Require Diet server
var server = require('diet')
// Require diet-jade plugin
var jade = require('diet-jade')({path: app.path + '/static/jade/'})

// Instantiate server
var app = server()
// Set server listening port
app.listen('http://localhost:8000')

// Assign jade plugin to the header
app.header(jade)

// Create a route
app.get('/', function($) {
// Render jade file! this will render ./yourConfiguredDirectory/index.jade
$.data.message = 'This is awesome!'
$.render('index')
})

app.get('/profile', function ($) {
// Render jade file! this will render ./.../yourConfiguredDirectory/profile.jade
$.render('profile')
})
```

**~/.../static/jade/index.jade**

```
p Received message: #{message}
```


## **File Rendering**

```js
$.render('yourFile') // will serve yourConfiguredDirectory/yourFile.jade

$.render('yourFile.jade') //wil serve yourConfiguredDirectory/yourFile.jade
```

## **License**
Please refer to [The License](./license).

[1]: http://jade-lang.com/
[2]: http://dietjs.com/
32 changes: 32 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const fs = require('fs');
const jade = require('jade')

/*
* Usage:
* var jade = require('diet-jade')({ path: app.path+'/static/jade' })
*
* app.header(jade)
*
* $.render('index') => $.render('index.jade')
*
*/

module.exports = function(options) {
var options = options || {}

return function($) {
$.render = function(filename) {
$.header('Content-Type', 'text/html; charset=UTF-8')
console.log(filename);

This comment has been minimized.

Copy link
@fabricionaweb

fabricionaweb Sep 11, 2016

It would be better without this log

This comment has been minimized.

Copy link
@tobbbles

tobbbles Sep 12, 2016

Owner

Sorry about this, I'll remove.

filename ? (filename.indexOf('.jade')>-1 ? (options.file = filename) : (options.file = filename + '.jade')) : ($.error('No jade file specified'))
var path = (options.path.slice(-1) === '/') ? options.path : options.path + '/'
var fn = jade.compileFile(path + options.file, {
pretty: true,
})
var html = fn($.data)
// console.log(html);
$.end(html)
}
$.return()
}
}
21 changes: 21 additions & 0 deletions license
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) <year> <copyright holders>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
38 changes: 38 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "diet-jade",
"version": "1.0.0",
"description": "Jade based diet plugin for rendering Jade HTML files",
"homepage": "http://github.com/mnzt/diet-jade/",
"keywords": [
"jade",
"html",
"parse",
"render",
"plugin",
"diet plugin",
"diet",
"dietjs",
"diet.js"
],
"bugs": {
"url": "http://github.com/mnzt/diet-jade/issues",
"email": "[email protected]"
},
"repository": {
"type": "git",
"url": "https://github.com/mnzt/diet-jade.git"
},
"license": "MIT",
"author": {
"name": "MNZT",
"email": "[email protected]",
"url": "http://github.com/mnzt"
},
"dependencies": {
"jade": "^1.11.0"
},
"main": "index.js",
"engines": {
"node": ">= 4.2.2"
}
}

0 comments on commit d623106

Please sign in to comment.