Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Implemented petal:block, based on tal:block from PHPTAL.

  • Loading branch information...
commit 6c6332fbec2626d8b7c16250762eb0b3f029c612 1 parent 95fc91a
Timothy Totten authored

Showing 3 changed files with 31 additions and 0 deletions. Show diff stats Hide diff stats

  1. +4 0 .gitignore
  2. +4 0 lib/Flower.pm
  3. +23 0 t/05-block.t
4 .gitignore
... ... @@ -0,0 +1,4 @@
  1 +*.pir
  2 +blib/
  3 +Makefile
  4 +*.swp
4 lib/Flower.pm
@@ -119,6 +119,10 @@ method !parse-element($element is rw) {
119 119 self!parse-tag($element, $tag, $petal);
120 120 if $element !~~ Exemel::Element { last; } # skip if we changed type.
121 121 }
  122 +## petal:block borrowed from PHPTAL.
  123 + if ($element ~~ Exemel::Element && $element.name eq $!petal~':block') {
  124 + $element = $element.nodes;
  125 + }
122 126 ## Haven't figured out METAL stuff entirely yet.
123 127 # for @metal -> $metal {
124 128 # my $tag = $!metal~':'~$metal;
23 t/05-block.t
... ... @@ -0,0 +1,23 @@
  1 +#!/usr/bin/env perl6
  2 +
  3 +## Based on the second repeat test, but using petal:block instead of omit-tag.
  4 +
  5 +BEGIN { @*INC.push: './lib' }
  6 +
  7 +use Test;
  8 +use Flower;
  9 +
  10 +plan 1;
  11 +
  12 +my $xml = '<?xml version="1.0"?>';
  13 +
  14 +my @items = (
  15 + { :alt<One>, :content<First> },
  16 + { :alt<Two>, :content<Second> },
  17 + { :alt<Three>, :content<Third> },
  18 +);
  19 +
  20 +my $template = '<test><petal:block petal:repeat="item items"><tr><td petal:content="item/alt"/><td petal:content="item/content"/></tr></petal:block></test>';
  21 +my $flower = Flower.new(:template($template));
  22 +is $flower.parse(:items(@items)), $xml~'<test><tr><td>One</td><td>First</td></tr><tr><td>Two</td><td>Second</td></tr><tr><td>Three</td><td>Third</td></tr></test>', 'petal:block with a repeated item.';
  23 +

0 comments on commit 6c6332f

Please sign in to comment.
Something went wrong with that request. Please try again.