Re: Component from a string?
Jonathan Swartz <[email protected]> Tue, 8 Jan 2013 09:27:58 -0800
| Newsgroups | gmane.comp.web.mason.user |
|---|---|
| Message-ID | <[email protected]> |
I haven't thought about how to do on-the-fly component compilation in Mason 2 yet. It made the code a lot cleaner not to have to plan for it, and I wasn't sure if anyone would need it. :) It should be possible since Class::MOP and Moose have utilities for creating classes on the fly. Let me know if you come up with a good solution. Jon On Jan 7, 2013, at 10:47 PM, Allan Engelhardt <[email protected]> wrote: > Thanks Rolf, but I am trying to use Mason2. Anyone know of a solution there? > > Allan > > On 7 January 2013 23:23, Rolf Schaufelberger <[email protected]> wrote: > Yes, > > Am 07.01.2013 um 22:55 schrieb Allan Engelhardt <[email protected]>: > >> Suppose I have a string (from a database or whatever) that I want to compile, run, and insert into the current component - is that possible? Something like (not tested): >> >> % # test.mc >> <%init> >> my $s = q{<p>I know 1+1=<% 1+1 %>.</p>}; # From external source >> </%init> >> <p>I know many facts</p> >> <% $m->magic( $s ) %> >> >> for some function magic( ... ) which should probably be called scomp_from_string or somesuch.... >> > > for HTML::Mason > see the docs for HTML::Mason::Interp::make_component > > > # Make an anonymous component > > my $anon_comp = > > eval { $interp->make_component > > ( comp_source => '<%perl>my $name = "World";</%perl>Hello <% $name %>!' ) }; > > die $@ if $@; > > > > $m->comp($anon_comp); > > > >> Allan > > Mit freundlichen Grüßen > Rolf Schaufelberger > > ------------------------------------------------------------------------------ > Master SQL Server Development, Administration, T-SQL, SSAS, SSIS, SSRS > and more. Get SQL Server skills now (including 2012) with LearnDevNow - > 200+ hours of step-by-step video tutorials by Microsoft MVPs and experts. > SALE $99.99 this month only - learn more at: > http://p.sf.net/sfu/learnmore_122512_______________________________________________ > Mason-users mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/mason-users ------------------------------------------------------------------------------ Master SQL Server Development, Administration, T-SQL, SSAS, SSIS, SSRS and more. Get SQL Server skills now (including 2012) with LearnDevNow - 200+ hours of step-by-step video tutorials by Microsoft MVPs and experts. SALE $99.99 this month only - learn more at: http://p.sf.net/sfu/learnmore_122512 _______________________________________________ Mason-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mason-users