Browse files

Add alias method "import" for "importXMLBuilder"

  • Loading branch information...
1 parent 2587fc5 commit c50cecbc84bd83dd0b9905c02bfbd2cc90b8e62d @piroor piroor committed Jul 26, 2012
Showing with 12 additions and 0 deletions.
  1. +1 −0 src/XMLFragment.coffee
  2. +11 −0 test/test.coffee
View
1 src/XMLFragment.coffee
@@ -409,6 +409,7 @@ class XMLFragment
c: (value) -> @comment value
r: (value) -> @raw value
u: () -> @up()
+ import: (xmlbuilder) -> @importXMLBuilder xmlbuilder
module.exports = XMLFragment
View
11 test/test.coffee
@@ -203,3 +203,14 @@ test12 = builder.begin('test12')
.importXMLBuilder(test12imported)
.doc().toString()
assert.strictEqual(xml12, test12)
+
+# Test the import() method (shorthand of importXMLBuilder)
+# This is important, because "important" can be a reserved word and
+# possibly causes syntax error in the future.
+xml13 = '<test13><test13imported/></test13>'
+test13imported = xmlbuilder.create().begin('test13imported')
+ .doc()
+test13 = builder.begin('test13')
+ .import(test13imported)
+ .doc().toString()
+assert.strictEqual(xml13, test13)

0 comments on commit c50cecb

Please sign in to comment.