My favorites | Sign in
Project Logo
                
Search
for
Updated Mar 04, 2009 by tobiasz.cudnik
codeToSelectorReplaceMethodPHP  

codeToSelectorReplace

Wiki > Syntax > codeTo > codeToSelectorReplace

Parameters

Description

Injects raw executable code replacing nodes matched by selector. Method uses actually matched nodes as root for the query.

Method doesn't change selected elements stack.

Example

Markup

 <p class='field1'>lorem ipsum</p>
 <p class='field2'>lorem ipsum</p>

Data

 $code = array(
     'field1' => 'print "abba";',
     'field2' => 'foreach(array(1, 2, 3) as $i) print $i'
 );

QueryTemplates formula

 $template->
     codeToSelectorReplace($code)
 ;

Template

 <?php  print "abba";  ?>
 <?php  foreach(array(1, 2, 3) as $i) print $i  ?>

Template tree before

 p.field1
  - Text:lorem ipsum
 p.field2
  - Text:lorem ipsum

Template tree after

 PHP
 PHP

See also

Comments allowed


Sign in to add a comment
Hosted by Google Code