Skip to content

Commit

Permalink
remove gen-closure-template sub, rename pod6 files
Browse files Browse the repository at this point in the history
  • Loading branch information
finanalyst committed Sep 24, 2022
1 parent 5126026 commit 61e1d70
Show file tree
Hide file tree
Showing 17 changed files with 127 additions and 49 deletions.
2 changes: 1 addition & 1 deletion META6.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Raku::Pod::Render",
"description": "A generic Pod6 Renderer with custom Pod::Blocks, FormatCodes for one or more files using templates, provides HTML and MarkDown.",
"version": "3.7.9",
"version": "3.7.10",
"perl": "6.d",
"authors": [
"Richard Hainsworth"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
32 changes: 24 additions & 8 deletions lib/Pod/To/HTML2.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -393,14 +393,30 @@ class Pod::To::HTML2 is ProcessedPod {
~ '</dd>'
},
'dlist-end' => sub ( %prm, %tml ) { "\n</dl>" },
'format-b' => gen-closure-template('strong'),
'format-c' => gen-closure-template('code'),
'format-i' => gen-closure-template('em'),
'format-k' => gen-closure-template('kbd'),
'format-r' => gen-closure-template('var'),
'format-t' => gen-closure-template('samp'),
'format-u' => gen-closure-template('u'),
'para' => gen-closure-template('p'),
'format-b' => sub ( %prm, %tml --> Str ) {
'<strong>' ~ (%prm<contents> // '') ~ '</strong>'
},
'format-c' => sub ( %prm, %tml --> Str ) {
'<code>' ~ (%prm<contents> // '') ~ '</code>'
},
'format-i' => sub ( %prm, %tml --> Str ) {
'<em>' ~ (%prm<contents> // '') ~ '</em>'
},
'format-k' => sub ( %prm, %tml --> Str ) {
'<kbd>' ~ (%prm<contents> // '') ~ '</kbd>'
},
'format-r' => sub ( %prm, %tml --> Str ) {
'<var>' ~ (%prm<contents> // '') ~ '</var>'
},
'format-t' => sub ( %prm, %tml --> Str ) {
'<samp>' ~ (%prm<contents> // '') ~ '</samp>'
},
'format-u' => sub ( %prm, %tml --> Str ) {
'<u>' ~ (%prm<contents> // '') ~ '</u>'
},
'para' => sub ( %prm, %tml --> Str ) {
'<p>' ~ (%prm<contents> // '') ~ '</p>'
},
'format-l' => sub ( %prm, %tml ) {
# transform a local file with an internal target
my $trg = %prm<target>;
Expand Down
16 changes: 8 additions & 8 deletions lib/RenderPod/Templating.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,14 @@ class RakuClosureTemplater is export {
}
}

#| A helper class for RakuClosureTemplates
sub gen-closure-template (Str $tag) is export {
my $start = '<' ~ $tag ~ '>';
my $end = '</' ~ $tag ~ '>';
return sub (%prm, %tml? --> Str) {
$start ~ (%prm<contents> // '') ~ $end;
}
}
##| A helper class for RakuClosureTemplates
#sub gen-closure-template (Str $tag) is export {
# my $start = '<' ~ $tag ~ '>';
# my $end = '</' ~ $tag ~ '>';
# return sub (%prm, %tml? --> Str) {
# $start ~ (%prm<contents> // '') ~ $end;
# }
#}

class MustacheTemplater is export {
# mustache acts on each template as it is given, and caches used ones.
Expand Down
33 changes: 24 additions & 9 deletions resources/html-rakuclosure.raku
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/env raku
use v6.d;
use RenderPod::Templating;

%(
# the following are extra for HTML files and are needed by the render (class) method
Expand Down Expand Up @@ -42,14 +41,30 @@ use RenderPod::Templating;
~ '</dd>'
},
'dlist-end' => sub ( %prm, %tml ) { "\n</dl>" },
'format-b' => gen-closure-template('strong'),
'format-c' => gen-closure-template('code'),
'format-i' => gen-closure-template('em'),
'format-k' => gen-closure-template('kbd'),
'format-r' => gen-closure-template('var'),
'format-t' => gen-closure-template('samp'),
'format-u' => gen-closure-template('u'),
'para' => gen-closure-template('p'),
'format-b' => sub ( %prm, %tml --> Str ) {
'<strong>' ~ (%prm<contents> // '') ~ '</strong>'
},
'format-c' => sub ( %prm, %tml --> Str ) {
'<code>' ~ (%prm<contents> // '') ~ '</code>'
},
'format-i' => sub ( %prm, %tml --> Str ) {
'<em>' ~ (%prm<contents> // '') ~ '</em>'
},
'format-k' => sub ( %prm, %tml --> Str ) {
'<kbd>' ~ (%prm<contents> // '') ~ '</kbd>'
},
'format-r' => sub ( %prm, %tml --> Str ) {
'<var>' ~ (%prm<contents> // '') ~ '</var>'
},
'format-t' => sub ( %prm, %tml --> Str ) {
'<samp>' ~ (%prm<contents> // '') ~ '</samp>'
},
'format-u' => sub ( %prm, %tml --> Str ) {
'<u>' ~ (%prm<contents> // '') ~ '</u>'
},
'para' => sub ( %prm, %tml --> Str ) {
'<p>' ~ (%prm<contents> // '') ~ '</p>'
},
'format-l' => sub ( %prm, %tml ) {
# transform a local file with an internal target
my $trg = %prm<target>;
Expand Down
32 changes: 24 additions & 8 deletions t-legacy/000-prepare-for-original-t.rakutest
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,30 @@ ok 1, 'creating html templates to match original hard coded html of original P2H
~ '</p></dd>'
},
'dlist-end' => sub ( %prm, %tml ) { "\n</dl>\n" },
'format-b' => gen-closure-template('strong'),
'format-c' => gen-closure-template('code'),
'format-i' => gen-closure-template('em'),
'format-k' => gen-closure-template('kbd'),
'format-r' => gen-closure-template('var'),
'format-t' => gen-closure-template('samp'),
'format-u' => gen-closure-template('u'),
'para' => gen-closure-template('p'),
'format-b' => sub ( %prm, %tml --> Str ) {
'<strong>' ~ (%prm<contents> // '') ~ '</strong>'
},
'format-c' => sub ( %prm, %tml --> Str ) {
'<code>' ~ (%prm<contents> // '') ~ '</code>'
},
'format-i' => sub ( %prm, %tml --> Str ) {
'<em>' ~ (%prm<contents> // '') ~ '</em>'
},
'format-k' => sub ( %prm, %tml --> Str ) {
'<kbd>' ~ (%prm<contents> // '') ~ '</kbd>'
},
'format-r' => sub ( %prm, %tml --> Str ) {
'<var>' ~ (%prm<contents> // '') ~ '</var>'
},
'format-t' => sub ( %prm, %tml --> Str ) {
'<samp>' ~ (%prm<contents> // '') ~ '</samp>'
},
'format-u' => sub ( %prm, %tml --> Str ) {
'<u>' ~ (%prm<contents> // '') ~ '</u>'
},
'para' => sub ( %prm, %tml --> Str ) {
'<p>' ~ (%prm<contents> // '') ~ '</p>'
},
'format-l' => sub ( %prm, %tml ) {
'<a href="'
~ (%prm<internal> ?? '#' !! '')
Expand Down
11 changes: 8 additions & 3 deletions xt/005-templates.rakutest
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
use v6.*;
use Test;

use ProcessedPod;
use RenderPod::Templating;
use Test::Output;

# A helper sub for RakuClosureTemplates
sub gen-closure-template (Str $tag) is export {
my $start = '<' ~ $tag ~ '>';
my $end = '</' ~ $tag ~ '>';
return sub (%prm, %tml? --> Str) {
$start ~ (%prm<contents> // '') ~ $end;
}
}
plan 7;

my $tmpl-fn = 'xt/newtemplates.raku';
Expand Down
14 changes: 10 additions & 4 deletions xt/035-pod-meta-data.rakutest
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
use Test;
use Test::Deeply::Relaxed;
use ProcessedPod;
use RenderPod::Templating;

# A helper class for RakuClosureTemplates
multi sub gen-closure-template (Str $tag) is export {
my $start = '<' ~ $tag ~ '>';
my $end = '</' ~ $tag ~ '>';
return sub (%prm, %tml? --> Str) {
$start ~ (%prm<contents> // '') ~ $end;
}
}
plan 4;

my $rv;
my $pro = ProcessedPod.new;
my $pv = 0;

Expand Down Expand Up @@ -58,7 +64,7 @@ is-deeply-relaxed $pro.pod-file.pod-config-data, %( :different("This is differen

=begin pod
=AUTHOR A.N. Writer
=SUMMARY Some summerised remarks
=SUMMARY Some summarised remarks

Stuff

Expand All @@ -72,7 +78,7 @@ like $pro.source-wrap,
.+ 'Stuff'
.+ '</body>'
'<meta>'
[ \s* 'Author=A.N. Writer' | \s* 'Summary=Some summerised remarks' ] **2
[ \s* 'Author=A.N. Writer' | \s* 'Summary=Some summarised remarks' ] **2
\s* '</meta></file>'
/, 'Got meta data structure';
done-testing;
13 changes: 9 additions & 4 deletions xt/040-filewrap.rakutest
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
use v6.*;
use Test;

use ProcessedPod;
use RenderPod::Templating;
my $rv;
# A helper sub for RakuClosureTemplates
sub gen-closure-template (Str $tag) is export {
my $start = '<' ~ $tag ~ '>';
my $end = '</' ~ $tag ~ '>';
return sub (%prm, %tml? --> Str) {
$start ~ (%prm<contents> // '') ~ $end;
}
}

my $processor = ProcessedPod.new;
my $pc = 0;

plan 2;

Expand Down
11 changes: 9 additions & 2 deletions xt/050-plugin.rakutest
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
use v6.*;
use Test;
use File::Directory::Tree;

use ProcessedPod;
use RenderPod::Templating;
# A helper sub for RakuClosureTemplates
sub gen-closure-template (Str $tag) is export {
my $start = '<' ~ $tag ~ '>';
my $end = '</' ~ $tag ~ '>';
return sub (%prm, %tml? --> Str) {
$start ~ (%prm<contents> // '') ~ $end;
}
}

my $rv;
my $processor = ProcessedPod.new;
my $pc = 0;
Expand Down
12 changes: 10 additions & 2 deletions xt/060-custom-formatting-codes.rakutest
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
use v6.*;
use Test;
use File::Directory::Tree;

use ProcessedPod;
use RenderPod::Templating;

# A helper sub for RakuClosureTemplates
sub gen-closure-template (Str $tag) is export {
my $start = '<' ~ $tag ~ '>';
my $end = '</' ~ $tag ~ '>';
return sub (%prm, %tml? --> Str) {
$start ~ (%prm<contents> // '') ~ $end;
}
}

my $rv;
my $processor = ProcessedPod.new;
my $pc = 0;
Expand Down

0 comments on commit 61e1d70

Please sign in to comment.