Last active
March 8, 2017 18:42
-
-
Save remorse/f59c149c52b805874cb473bf4a39b6ac to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl6 | |
my %p = (:date-gmt("XXX"), :id("XXX"), :slug("XXX"), :tags($["Galaxy", "Galaxy fan render", "planet"]), :type("photo"), :url("http://XXX"), :url-with-slug("http://XXX")); | |
my %post = ( | |
'_post' => %p, | |
'_type' => %p{'type'}, | |
'post_id' => %p{'id'}, | |
'post_slug' => %p{'slug'} || %p{'type'}, | |
'post_url' => %p{'url-with-slug'} || %p{'url'}, | |
'post_date' => %p{'date-gmt'}, | |
'post_tags' => '', | |
'post_body' => '', | |
); | |
# fix tags -- doesn't work | |
if (%p<tags>) { | |
%post{'post_tags'} = { 'tags' => [] }; | |
for %p{'tags'} -> $tag { | |
%post{'post_tags'}{'tags'}.push( { 'tag' => $tag }); | |
} | |
} | |
say %post.perl; | |
# if instead of `for %p{'tags'} -> $tag`, I do `for %p{'tags'}:v -> $tag`, it does work. | |
# perl 5 version: | |
# fix tags | |
# if ( scalar( $p->{'tags'} ) ) { | |
# $post->{'post_tags'} = { 'tags' => [] }; | |
# foreach my $tag ( $p->{'tags'}->@* ) { | |
# push $post->{'post_tags'}{'tags'}->@*, { | |
# 'tag' => $tag, | |
# }; | |
# } | |
# } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment