Nested Templates

Automate population of templates within templates: Inception style

About Space


Everyone should learn about Space. I learned in 4th grade. Below is what I learned.

I learned all about neptune in school. My favorite fact is: Neptune is the blue planet. I still remember this stuff in 2021.

I also learned about Geology. It's very important! Here's a fact: Neptune is the blue planet


# require the templating library 
require '../source/smallaxe-templating.php'

# first, you instantiate a Small Axe object
$T = new Smallaxe\smallaxe_template();

# set the template path

$data = [
'fact'=>"Space is really, really big",
'demo4-2.tmpl' => ['subject'=>'neptune''fact'=>"Neptune is the blue planet"],
'demo4-3.tmpl' => ['subject'=>'geology' ]

# load template
$template    $T->load_template("demo4-1");

        <title>About {{subject}}</title>
        <h1>ABOUT {{subject|upper}}</h1>
        <p>Everyone should learn about {{subject}}. I learned in {{grade|int}}{{suffix|sup}} grade. Below is what I learned.</p>
        {{@template file=demo4-2.tmpl}}
<p>I learned all about {{subject|lower}} in school. My favorite fact is: {{fact}}. I still remember this stuff in [[year]]. </p>

<p>{{@template file=demo4-3.tmpl}}</p>
I also learned about {{subject|ucfirst}}. It's very important! Here's a fact: {{fact}}