Skip to content
This repository has been archived by the owner on Jun 10, 2018. It is now read-only.

Commit

Permalink
'eco.link' is now just 'eco'
Browse files Browse the repository at this point in the history
  • Loading branch information
sstephenson committed Sep 26, 2010
1 parent 2fa3f94 commit b7c91b1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions lib/eco/compiler.coffee
Expand Up @@ -2,7 +2,11 @@ CoffeeScript = require "coffee-script"
{preprocess} = require "eco/preprocessor"
{indent} = require "eco/util"

exports.compile = compile = (source, options) ->
module.exports = eco = (source) ->
(new Function "module", compile source) module = {}
module.exports

eco.compile = compile = (source, options) ->
identifier = options?.identifier ? "module.exports"
identifier = "var #{identifier}" unless identifier.match(/\./)
script = CoffeeScript.compile preprocess(source), noWrap: true
Expand Down Expand Up @@ -53,12 +57,8 @@ exports.compile = compile = (source, options) ->
};
"""

exports.link = link = (source) ->
(new Function "module", compile source) module = {}
module.exports

exports.render = (source, data) ->
(link source) data
eco.render = (source, data) ->
(eco source) data

if require.extensions
require.extensions[".eco"] = (module, filename) ->
Expand Down
4 changes: 2 additions & 2 deletions test/test_render.coffee
Expand Up @@ -8,12 +8,12 @@ items = [

module.exports =
"linking hello.eco": (test) ->
render = eco.link fixture("hello.eco")
render = eco fixture("hello.eco")
test.same fixture("hello.out.1"), render name: "Sam"
test.done()

"linked templates can be reused": (test) ->
render = eco.link "Hello <%= @name %>"
render = eco "Hello <%= @name %>"
test.same "Hello Sam", render name: "Sam"
test.same "Hello Josh", render name: "Josh"
test.done()
Expand Down

0 comments on commit b7c91b1

Please sign in to comment.