Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^13: Thanks to Ikegami, Chromatic & Corion

by Logicus
on Nov 03, 2011 at 01:33 UTC ( #935540=note: print w/replies, xml ) Need Help??


in reply to Re^12: Thanks to Ikegami, Chromatic & Corion
in thread Thanks to Ikegami, Chromatic & Corion

I tend not to put any HTML into the plugin code, but instead send it to the plugin from the document level.

<ul> <some_list_creating_plugin> <li><some_marker></li> </some_list_creating_plugin> </ul> some_list_creating_plugin => sub { my @list = ['foo','bar','baz']; my $mask = $_[0]; my $result; foreach my $item (@list) { my $maskCopy = $mask; $maskCopy =~ s@<some_marker>@$item@gs; push (@results, $maskCopy); } return join (@results); } output ------ <ul> <li>foo</li> <li>bar</li> <li>baz</li> </ul>

Replies are listed 'Best First'.
Re^14: Thanks to Ikegami, Chromatic & Corion
by ikegami (Pope) on Nov 03, 2011 at 01:54 UTC

    $maskCopy =~ s@<some_marker>@$item@gs;

    But what if $item was HTML from a database instead of being hardcoded aXML...

      Well you wouldn't want to be putting the <ul> tags in then.

      Ok so...

      If our database looked like this

      pageid int primary key auto_increment, name varchar(255), html text Then (db_get)pages.name="(sqd)name(/sqd)".html(/db_get)

      Then localhost:5000?action=test&name=homepage will be displaying the contents of the html column of the pages db.

        Did your post get cut short? You were trying to prove to me that your plugin wasn't buggy.

        Or are you saying that the result of (plugin)(/plugin) isn't searched for tags? I thought it was the same as <plugin></plugin> except for precedence.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://935540]
help
Chatterbox?
[choroba]: My week was hectic as well, and so will be the next several ones...
[Corion]: Sane Dots Supplies - your brand manufacturer for satisfying experiences!
[choroba]: preparing the trip to Vietnam + buying a new car = enough fun
[Corion]: choroba: Yeah, that's a lot of "fun" for one week...
[Corion]: I guess I should stage some product photos for Sane Dots Supplies ;)
[marto]: I had some ideas about that Corion
[marto]: I'll send a message over the weekend maybe :P
[Corion]: choroba: I avoided the "fun" of emergency shopping for a new flat iron by trying the flat iron without the timer that sat between it and the mains power. Seems as if just the timer is broken.
[Corion]: marto: Heh, would be cool!

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (7)
As of 2017-01-20 10:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you watch meteor showers?




    Results (174 votes). Check out past polls.