Permalink
Browse files

ENHANCEMENT: Allow arguments to be passed to templates via an array p…

…assed to SSViewer#process and via keyword=value pairs in the <% include %> tag
  • Loading branch information...
1 parent 40ca21e commit e4a043ac0b642bc624a54550a9e484154bdb7d29 Hamish Friedlander committed Apr 11, 2012
@@ -0,0 +1 @@
+<p>$Arg1</p><p>$Arg2</p>
@@ -443,6 +443,33 @@ function testBaseTagGeneration() {
$this->assertRegExp('/<head><base href=".*" \/><\/head>/', $response->getBody());
}
+ function testIncludeWithArguments() {
+ $this->assertEquals(
+ $this->render('<% include SSViewerTestIncludeWithArguments %>'),
+ '<p>[out:Arg1]</p><p>[out:Arg2]</p>'
+ );
+
+ $this->assertEquals(
+ $this->render('<% include SSViewerTestIncludeWithArguments Arg1=A %>'),
+ '<p>A</p><p>[out:Arg2]</p>'
+ );
+
+ $this->assertEquals(
+ $this->render('<% include SSViewerTestIncludeWithArguments Arg1=A, Arg2=B %>'),
+ '<p>A</p><p>B</p>'
+ );
+
+ $this->assertEquals(
+ $this->render('<% include SSViewerTestIncludeWithArguments Arg1=A Bare String, Arg2=B Bare String %>'),
+ '<p>A Bare String</p><p>B Bare String</p>'
+ );
+
+ $this->assertEquals(
+ $this->render('<% include SSViewerTestIncludeWithArguments Arg1="A", Arg2=$B %>', new ArrayData(array('B' => 'Bar'))),
+ '<p>A</p><p>Bar</p>'
+ );
+ }
+
function testRecursiveInclude() {
$view = new SSViewer(array('SSViewerTestRecursiveInclude'));
Oops, something went wrong. Retry.

0 comments on commit e4a043a

Please sign in to comment.