Skip to content

Commit

Permalink
Clean up repository with gitignore.
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Sköld committed Aug 12, 2009
1 parent c1368e2 commit 3af5850
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 16 deletions.
Binary file removed .DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
.DS_Store
Binary file removed public/.DS_Store
Binary file not shown.
Binary file modified public/ehx.n
Binary file not shown.
Binary file modified public/tests.n
Binary file not shown.
16 changes: 8 additions & 8 deletions source/ehx/Ehx.hx
Expand Up @@ -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 = "";
Expand Down Expand Up @@ -63,15 +63,15 @@ class Ehx {

public static function main() {
var ehx = new Ehx();
var scope = {
var context = {
str: "hello there",
num: 12,
arr: ["abc",123],
func: function() {
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 ) );
}
}

Expand Down Expand Up @@ -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 ) );
}

/**
Expand Down
Binary file removed source/tests/.DS_Store
Binary file not shown.
16 changes: 8 additions & 8 deletions source/tests/TestEhx.hx
Expand Up @@ -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() {
Expand All @@ -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 ) ) {
Expand Down

0 comments on commit 3af5850

Please sign in to comment.