diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 0ff6859..0000000 Binary files a/.DS_Store and /dev/null differ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e43b0f9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.DS_Store diff --git a/public/.DS_Store b/public/.DS_Store deleted file mode 100644 index b2e178f..0000000 Binary files a/public/.DS_Store and /dev/null differ diff --git a/public/ehx.n b/public/ehx.n index e35fb0b..da646ad 100644 Binary files a/public/ehx.n and b/public/ehx.n differ diff --git a/public/tests.n b/public/tests.n index 2c66254..9e5e1e7 100644 Binary files a/public/tests.n and b/public/tests.n differ diff --git a/source/ehx/Ehx.hx b/source/ehx/Ehx.hx index b09569f..2e7f183 100644 --- a/source/ehx/Ehx.hx +++ b/source/ehx/Ehx.hx @@ -8,11 +8,11 @@ class Ehx { processor = new CmdProcessor(); } - public function render( file , ?scope : Dynamic = null ) { + public function render( file , ?context : Dynamic = null ) { var startTime = haxe.Timer.stamp(); - if( scope != null ) - processor.addScope( scope ); + if( context != null ) + processor.addContext( context ); var r = ~/<%(.*?)%>/sm; var results = ""; @@ -63,7 +63,7 @@ class Ehx { public static function main() { var ehx = new Ehx(); - var scope = { + var context = { str: "hello there", num: 12, arr: ["abc",123], @@ -71,7 +71,7 @@ class Ehx { return "this is from a function!"; } } - trace( ehx.render( neko.io.File.getContent( "index.ehx" ) , scope ) ); + trace( ehx.render( neko.io.File.getContent( "index.ehx" ) , context ) ); } } @@ -140,9 +140,9 @@ class CmdProcessor { var _:haxe.Unserializer; } - public function addScope( scope : Dynamic ) { - for( field in Reflect.fields( scope ) ) - interp.variables.set( field , Reflect.field( scope , field ) ); + public function addContext( context : Dynamic ) { + for( field in Reflect.fields( context ) ) + interp.variables.set( field , Reflect.field( context , field ) ); } /** diff --git a/source/tests/.DS_Store b/source/tests/.DS_Store deleted file mode 100644 index 5008ddf..0000000 Binary files a/source/tests/.DS_Store and /dev/null differ diff --git a/source/tests/TestEhx.hx b/source/tests/TestEhx.hx index e92bdcf..3cbb9e3 100644 --- a/source/tests/TestEhx.hx +++ b/source/tests/TestEhx.hx @@ -28,21 +28,21 @@ class TestSyntax extends haxe.unit.TestCase, implements haxe.Public { } function testScopedVariable() { - var scope = { str: "hello world" }; + var context = { str: "hello world" }; var markup = "<% print( str ) %>"; - assertEquals( "hello world" , ehx.render( markup , scope ) ); + assertEquals( "hello world" , ehx.render( markup , context ) ); } function testScopedArray() { - var scope = { arr: ["one",2] }; + var context = { arr: ["one",2] }; var markup = "<% print( arr.join(\"#\") ) %>"; - assertEquals( "one#2" , ehx.render( markup , scope ) ); + assertEquals( "one#2" , ehx.render( markup , context ) ); } function testScopedFunction() { - var scope = { func: function() { return "from func!"; } }; + var context = { func: function() { return "from func!"; } }; var markup = "<% print( func() ) %>"; - assertEquals( "from func!" , ehx.render( markup , scope ) ); + assertEquals( "from func!" , ehx.render( markup , context ) ); } function testQuickPrint() { @@ -64,9 +64,9 @@ class TestFixtures extends haxe.unit.TestCase { ehx = new ehx.Ehx(); } - function assertFixture( name , ?scope : Dynamic = null ) { + function assertFixture( name , ?context : Dynamic = null ) { try { - assertEquals( neko.io.File.getContent( fixturesPath + name + ".html" ) , ehx.render( neko.io.File.getContent( fixturesPath + name + ".ehx" ) , scope ) ); + assertEquals( neko.io.File.getContent( fixturesPath + name + ".html" ) , ehx.render( neko.io.File.getContent( fixturesPath + name + ".ehx" ) , context ) ); } catch( test : haxe.unit.TestStatus ) { var r = ~/expected '(.+)' but was '(.+)'/gs; if( r.match( test.error ) ) {