Browse files

package name is now asyncxml and doesnt include template anymore

  • Loading branch information...
1 parent f4c0820 commit 20e1f41ba6bde931153d0652ea4a36f8be6398c7 @dodo committed Oct 22, 2011
Showing with 12 additions and 151 deletions.
  1. +0 −2 async-xml.js
  2. +2 −0 asyncxml.js
  3. +4 −4 package.json
  4. +0 −5 src/async-xml.coffee
  5. +4 −0 src/asyncxml.coffee
  6. +0 −90 src/template.coffee
  7. +0 −48 src/test/template.coffee
  8. +1 −1 src/test/xml.coffee
  9. +1 −1 wscript
View
2 async-xml.js
@@ -1,2 +0,0 @@
-
-module.exports = require('./build/default/async-xml')
View
2 asyncxml.js
@@ -0,0 +1,2 @@
+
+module.exports = require('./build/default/asyncxml')
View
8 package.json
@@ -1,10 +1,10 @@
-{ "name": "async-xml"
+{ "name": "asyncxml"
, "description": "async xml builder and generator"
, "version": "0.0.0"
-, "homepage": "https://github.com/dodo/node-async-xml"
+, "homepage": "https://github.com/dodo/node-asyncxml"
, "author": "dodo (https://github.com/dodo)"
-, "repository": {"type": "git", "url": "git://github.com/dodo/node-async-xml.git"}
-, "main": "async-xml.js"
+, "repository": {"type": "git", "url": "git://github.com/dodo/node-asyncxml.git"}
+, "main": "asyncxml.js"
, "engines": {"node": "0.4.x"}
, "keywords": ["async", "xml", "generation", "stream"]
, "scripts": {
View
5 src/async-xml.coffee
@@ -1,5 +0,0 @@
-
-{ Tag, Builder } = require './xml'
-Template = require './template'
-
-@asyncxml = module.exports = { Tag, Builder, Template }
View
4 src/asyncxml.coffee
@@ -0,0 +1,4 @@
+
+{ Tag, Builder } = require './xml'
+
+@asyncxml = module.exports = { Tag, Builder }
View
90 src/template.coffee
@@ -1,90 +0,0 @@
-{ EventEmitter } = require 'events'
-{ Builder } = require './xml'
-
-
-schema =
- 'xml' : -> "" # allready includes tag
- 'html' : ->
- "#{do schema.xml } #{do schema['html-obsolete']} iframe label legend " +
- "#{do self_closing.html} html body div ul li a b body button colgroup "+
- "dfn div dl dt em dd del form h1 h2 h3 h4 h5 h6 head hgroup html ins " +
- "li map i mark menu meter nav noscript object ol optgroup option p " +
- "pre script select small span strong style sub sup table tbody tfoot " +
- "td textarea th thead title tr u ul"
- 'html5': ->
- "#{do schema.html} #{do self_closing.html5} section article video q s "+
- "audio abbr address aside bdi bdo blockquote canvas caption cite code "+
- "datalist details fieldset figcaption figure footer header kbd output "+
- "progress rp rt ruby samp summary time"
- 'html-obsolete': ->
- "applet acronym bgsound dir frameset noframes isindex listing nextid " +
- "noembed plaintext rb strike xmp big blink center font marquee nobr " +
- "multicol spacer tt"
-
-
-# Valid self-closing HTML 5 elements.
-# set true when all tags are self closing
-self_closing =
- 'xml' : -> on
- 'html5': -> "#{do self_closing.html} base command keygen source track wbr"
- 'html' : -> "area br col embed hr img input link meta param"
-
-
-fill_with_tags = (tag, tags) ->
- tags.split(' ').forEach (name) ->
- return unless name
- tag[ name] = (args...) -> tag.tag( name, args...)
- tag["$"+name] = (args...) -> tag.$tag(name, args...)
- return tag
-
-
-class Template extends EventEmitter
- constructor: (opts = {}, template) ->
- [template, opts] = [opts, {}] if typeof opts is 'function'
- opts.self_closing = self_closing[opts.schema ? 'xml']?()
- opts.schema = schema[opts.schema ? 'xml']?()
- opts.end ?= on
-
- class ExtendedBuilder
- constructor: ->
- fill_with_tags this, opts.schema
- Builder.apply this, arguments
- for name, method of Builder::
- ExtendedBuilder::[name] = method
-
- @xml = new ExtendedBuilder
- @end = @xml.end
- Tag = @xml.Tag
- class ExtendedTag
- constructor: ->
- fill_with_tags this, opts.schema
- Tag.apply this, arguments
- @xml.Tag = @xml.opts.Tag = ExtendedTag
- for name, method of Tag::
- ExtendedTag::[name] = method
- end_tag = Tag::end
- @xml.Tag::end = (args...) ->
- if opts.self_closing is on or opts.self_closing.match @name
- end_tag.call this, args...
- else
- @text "", force:yes if @headers
- end_tag.call this, args...
-
- @xml.on 'data', (args...) =>
- @emit 'data', args...
- @xml.on 'end', (args...) =>
- @emit 'end', args...
-
- process.nextTick =>
- if typeof template is 'function'
- template.call @xml
- @end() if opts.end
- else
- @xml.end(template)
-
-
-# exports
-
-Template.schema = schema
-module.exports = Template
-Template.self_closing = self_closing
View
48 src/test/template.coffee
@@ -1,48 +0,0 @@
-path = require 'path'
-{ readFile } = require 'fs'
-{ Template } = require '../async-xml'
-
-module.exports =
-
- simple: (æ) ->
- xml = new Template ->
- @$tag('test')
- xml.on 'end', æ.done
- xml.on 'data', (tag) -> æ.equal "<test/>", tag
-
-
- html5: (æ) ->
- content = ["a", "b", "c"]
- xml = new Template schema:'html5', ->
- @$html ->
- @body ->
- readFile path.join(__dirname,"filename"), (err, filedata) =>
- @$div class:'test', filedata
- @$ul ->
- content.forEach (data) =>
- li = @$li({'data-content':data}, data)
- @end()
-
-
- xml.on 'end', æ.done
- xml.on 'data', (tag) -> æ.equal results.shift(), tag
- results = [
- '<html>'
- '<body>'
- '<div class="test">'
- 'hello world\n'
- '</div>'
- '<ul>'
- '<li data-content="a">'
- 'a'
- '</li>'
- '<li data-content="b">'
- 'b'
- '</li>'
- '<li data-content="c">'
- 'c'
- '</li>'
- '</ul>'
- '</body>'
- '</html>'
- ]
View
2 src/test/xml.coffee
@@ -1,6 +1,6 @@
path = require 'path'
{ createReadStream } = require 'fs'
-{ Tag, Builder } = require '../async-xml'
+{ Tag, Builder } = require '../asyncxml'
module.exports =
View
2 wscript
@@ -30,7 +30,7 @@ def build(ctx):
source = file.srcpath()[3:],
target = tgtpath)
- file = ctx.path.find_dir("src").ant_glob("**/async-xml.coffee", flat=False)[0]
+ file = ctx.path.find_dir("src").ant_glob("**/asyncxml.coffee", flat=False)[0]
tgtpath = file.change_ext(".browser.js").bldpath(env)[5:]
ctx.path.exclusive_build_node(tgtpath)
ctx(name = "browserify",

0 comments on commit 20e1f41

Please sign in to comment.