Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Clean up repository with gitignore.

  • Loading branch information...
commit 3af58509503b342a4ca1ee9e1733e91fec199df0 1 parent c1368e2
Robert Sköld authored
View
BIN  .DS_Store
Binary file not shown
View
1  .gitignore
@@ -0,0 +1 @@
+.DS_Store
View
BIN  public/.DS_Store
Binary file not shown
View
BIN  public/ehx.n
Binary file not shown
View
BIN  public/tests.n
Binary file not shown
View
16 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 ) );
}
/**
View
BIN  source/tests/.DS_Store
Binary file not shown
View
16 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 ) ) {
Please sign in to comment.
Something went wrong with that request. Please try again.