hand-ect
v0.0.2
Published
support Http Stateful by Cookie and Session for handover, compatible with connect/express,
Downloads
3
Readme
hand-ect
support
ect
template system throughres.ect
supporthelpers
function in view compatible with connec/express
Examples
ho = require 'handover'
ect = require '../hand-ect'
http = require 'http'
ect.global.upperHelper = (string) -> # global scope, apply every view
return string.toUpperCase();
hand = (req,res,next)->
data =
title : 'Hello, world!',
id : 'main',
links: [
{ name : 'Google', url : 'http://google.com/' },
{ name : 'Facebook', url : 'http://facebook.com/' },
{ name : 'Twitter', url : 'http://twitter.com/' }
],
upperHelper : (string) -> # local scope, apply this view
return string.toUpperCase();
res.ect 'sample.ect', data
server = http.createServer ho.make [
ect
ectOption:
ext: '.ect'
root : 'test'
hand
]
# or with connect/express
connect = require 'connect'
app = connect()
app.use ect()
app.use hand
Important! - Shadowing of Datas
ect.global < res.data < argument 'data'
#Given
ect.global.foo = 'a'
res.foo = 'b'
#result is b
#Given
ect.global.foo = 'a'
res.foo = 'b'
res.ect 'sample.ect', { foo : 'c'}
#result is c
License
(The MIT License)
Copyright (c) 2014 junsik <[email protected]@google.com>
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.