Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

renaming

  • Loading branch information...
commit ef77e1cbef7325c3ebc5d7ea71e10beb49ed7b78 1 parent e4045f3
Gradus Parnassum authored
8 bin/coffeecup
View
@@ -17,7 +17,7 @@ else
render = (input_path, output_directory) ->
fs.readFile input_path, (err, contents) ->
throw err if err
- html = coffeekup.render String(contents), options
+ html = coffeecup.render String(contents), options
write input_path, html, output_directory
write = (input_path, html, output_directory) ->
@@ -35,7 +35,7 @@ write = (input_path, html, output_directory) ->
usage = '''
Usage:
- coffeekup [options] path/to/template.coffee
+ coffeecup [options] path/to/template.coffee
'''
switches = [
@@ -44,7 +44,7 @@ switches = [
['-p', '--print', 'print the compiled html to stdout']
['-f', '--format', 'apply line breaks and indentation to html output']
['-u', '--utils', 'add helper locals (currently only "render")']
- ['-v', '--version', 'display CoffeeKup version']
+ ['-v', '--version', 'display coffeecup version']
['-h', '--help', 'display this help message']
]
@@ -78,7 +78,7 @@ if options.utils
if print_summary
puts parser.toString()
else if print_version
- puts coffeekup.version
+ puts coffeecup.version
else if args.length > 0
file = args[0]
32 docs/reference.md
View
@@ -1,12 +1,12 @@
-# CoffeeKup 0.3.1 Reference
+# coffeecup 0.3.1 Reference
-## The CoffeeKup object
+## The coffeecup object
-Both the returned value from `require 'coffeekup'` and the global `CoffeeKup` created by `<script src="coffeekup.js">` will have the following attributes:
+Both the returned value from `require 'coffeecup'` and the global `coffeecup` created by `<script src="coffeecup.js">` will have the following attributes:
### compile
-`CoffeeKup.compile(template, options)`
+`coffeecup.compile(template, options)`
Compiles the template to a standalone function and returns it.
@@ -34,7 +34,7 @@ All attributes in `data` will be available to the template at `@` (`this`). Some
### render
-`CoffeeKup.render(template, data, options)`
+`coffeecup.render(template, data, options)`
Compiles the template provided, runs it, and returns the resulting HTML string.
@@ -44,7 +44,7 @@ Options:
### version
-Version of CoffeeKup running.
+Version of coffeecup running.
### doctypes
@@ -62,7 +62,7 @@ List of self-closing tags. Array of strings, can be customized.
## The template scope
-CoffeeKup templates are CoffeeScript/JavaScript functions with certain special variables put in their local scope. These are usually functions, which will write their equivalent HTML to a buffer. The contents of this buffer will be the final return value of the template.
+coffeecup templates are CoffeeScript/JavaScript functions with certain special variables put in their local scope. These are usually functions, which will write their equivalent HTML to a buffer. The contents of this buffer will be the final return value of the template.
### Tag functions
@@ -150,7 +150,7 @@ ID/class shortcut
#### doctype
-Writes the doctype. Usage: `doctype()` (picks the default), `doctype 'xml'` (specifying). You can see and modify the list of doctypes at `CoffeeKup.doctypes`.
+Writes the doctype. Usage: `doctype()` (picks the default), `doctype 'xml'` (specifying). You can see and modify the list of doctypes at `coffeecup.doctypes`.
#### comment
@@ -207,7 +207,7 @@ Without it, the `a` function runs first, writes to the buffer and returns `null`
CoffeeScript shortcut to `this`. This is where all the input data can be accessed.
-## Extending CoffeeKup
+## Extending coffeecup
template = ->
h1 @title
@@ -222,16 +222,16 @@ CoffeeScript shortcut to `this`. This is where all the input data can be accesse
attrs.name = attrs.id
input attrs
- console.log CoffeeKup.render template, title: 'Log In', hardcode: helpers
+ console.log coffeecup.render template, title: 'Log In', hardcode: helpers
-## The coffeekup command
+## The coffeecup command
-When installing CoffeeKup with `npm install coffeekup -g`, you get a `coffeekup` command that allows you to generate HTML from CoffeeKup templates:
+When installing coffeecup with `npm install coffeecup -g`, you get a `coffeecup` command that allows you to generate HTML from coffeecup templates:
- $ coffeekup -h
+ $ coffeecup -h
Usage:
- coffeekup [options] path/to/template.coffee
+ coffeecup [options] path/to/template.coffee
--js compile template to js function
-n, --namespace global object holding the templates (default: "templates")
@@ -240,5 +240,5 @@ When installing CoffeeKup with `npm install coffeekup -g`, you get a `coffeekup`
-p, --print print the compiled html to stdout
-f, --format apply line breaks and indentation to html output
-u, --utils add helper locals (currently only "render")
- -v, --version display CoffeeKup version
- -h, --help display this help message
+ -v, --version display coffeecup version
+ -h, --help display this help message
46 src/coffeekup.coffee → src/coffeecup.coffee
View
@@ -1,4 +1,4 @@
-# **CoffeeKup** lets you to write HTML templates in 100% pure
+# **CoffeeCup** lets you to write HTML templates in 100% pure
# [CoffeeScript](http://coffeescript.org).
#
# You can run it on [node.js](http://nodejs.org) or the browser, or compile your
@@ -10,19 +10,19 @@
# stiff.
if window?
- coffeekup = window.CoffeeKup = {}
+ coffeecup = window.coffeecup = {}
coffee = if CoffeeScript? then CoffeeScript else null
else
- coffeekup = exports
+ coffeecup = exports
coffee = require 'coffee-script'
compiler = require __dirname + '/compiler'
- compiler.setup coffeekup
+ compiler.setup coffeecup
-coffeekup.version = '0.3.1edge'
+coffeecup.version = '0.3.1edge'
# Values available to the `doctype` function inside a template.
# Ex.: `doctype 'strict'`
-coffeekup.doctypes =
+coffeecup.doctypes =
'default': '<!DOCTYPE html>'
'5': '<!DOCTYPE html>'
'xml': '<?xml version="1.0" encoding="utf-8" ?>'
@@ -88,13 +88,13 @@ merge_elements = (args...) ->
# Public/customizable list of possible elements.
# For each name in this list that is also present in the input template code,
# a function with the same name will be added to the compiled template.
-coffeekup.tags = merge_elements 'regular', 'obsolete', 'void', 'obsolete_void'
+coffeecup.tags = merge_elements 'regular', 'obsolete', 'void', 'obsolete_void'
# Public/customizable list of elements that should be rendered self-closed.
-coffeekup.self_closing = merge_elements 'void', 'obsolete_void'
+coffeecup.self_closing = merge_elements 'void', 'obsolete_void'
# This is the basic material from which compiled templates will be formed.
-# It will be manipulated in its string form at the `coffeekup.compile` function
+# It will be manipulated in its string form at the `coffeecup.compile` function
# to generate the final template function.
skeleton = (data = {}) ->
# Whether to generate formatted HTML with indentation and line breaks, or
@@ -105,7 +105,7 @@ skeleton = (data = {}) ->
# basis with the `h` function.
data.autoescape ?= off
- # Internal CoffeeKup stuff.
+ # Internal coffeecup stuff.
__ck =
buffer: []
@@ -276,7 +276,7 @@ skeleton = String(skeleton)
skeleton = coffeescript_helpers + skeleton
# Compiles a template into a standalone JavaScript function.
-coffeekup.compile = (template, options = {}) ->
+coffeecup.compile = (template, options = {}) ->
# The template can be provided as either a function or a CoffeeScript string
# (in the latter case, the CoffeeScript compiler must be available).
if typeof template is 'function' then template = String(template)
@@ -306,7 +306,7 @@ coffeekup.compile = (template, options = {}) ->
tag_functions = ''
tags_used = []
- for t in coffeekup.tags
+ for t in coffeecup.tags
if template.indexOf(t) > -1 or hardcoded_locals.indexOf(t) > -1
tags_used.push t
@@ -317,9 +317,9 @@ coffeekup.compile = (template, options = {}) ->
# Main function assembly.
code = tag_functions + hardcoded_locals + skeleton
- code += "__ck.doctypes = #{JSON.stringify coffeekup.doctypes};"
+ code += "__ck.doctypes = #{JSON.stringify coffeecup.doctypes};"
code += "__ck.coffeescript_helpers = #{JSON.stringify coffeescript_helpers};"
- code += "__ck.self_closing = #{JSON.stringify coffeekup.self_closing};"
+ code += "__ck.self_closing = #{JSON.stringify coffeecup.self_closing};"
# If `locals` is set, wrap the template inside a `with` block. This is the
# most flexible but slower approach to specifying local variables.
@@ -332,7 +332,7 @@ coffeekup.compile = (template, options = {}) ->
cache = {}
-# Template in, HTML out. Accepts functions or strings as does `coffeekup.compile`.
+# Template in, HTML out. Accepts functions or strings as does `coffeecup.compile`.
#
# Accepts an option `cache`, by default `false`. If set to `false` templates will
# be recompiled each time.
@@ -341,7 +341,7 @@ cache = {}
# data, but the two will be merged and passed down to the compiler (which uses
# `locals` and `hardcode`), and the template (which understands `locals`, `format`
# and `autoescape`).
-coffeekup.render = (template, data = {}, options = {}) ->
+coffeecup.render = (template, data = {}, options = {}) ->
data[k] = v for k, v of options
data.cache ?= off
@@ -350,15 +350,15 @@ coffeekup.render = (template, data = {}, options = {}) ->
if data.optimize and not data.cache then data.optimize = no
if data.cache and cache[template]? then tpl = cache[template]
- else if data.cache then tpl = cache[template] = coffeekup.compile(template, data)
- else tpl = coffeekup.compile(template, data)
+ else if data.cache then tpl = cache[template] = coffeecup.compile(template, data)
+ else tpl = coffeecup.compile(template, data)
tpl(data)
unless window?
- coffeekup.adapters =
- # Legacy adapters for when CoffeeKup expected data in the `context` attribute.
- simple: coffeekup.render
- meryl: coffeekup.render
+ coffeecup.adapters =
+ # Legacy adapters for when coffeecup expected data in the `context` attribute.
+ simple: coffeecup.render
+ meryl: coffeecup.render
express:
TemplateError: class extends Error
@@ -374,7 +374,7 @@ unless window?
text @partial.apply @, arguments
TemplateError = @TemplateError
- try tpl = coffeekup.compile(template, data)
+ try tpl = coffeecup.compile(template, data)
catch e then throw new TemplateError "Error compiling #{data.filename}: #{e.message}"
return ->
Please sign in to comment.
Something went wrong with that request. Please try again.