Talesoft / tale-jade

A complete and fully-functional implementation of the Jade template language for PHP
http://jade.talesoft.codes
MIT License
88 stars 10 forks source link

Allow import args! #6

Open TorbenKoehn opened 9 years ago

TorbenKoehn commented 9 years ago

Import's actually support Attributes right now.

extends some-file(foo='bar', 'baz') is perfectly valid right now and the import node will get the correct attributes appended to ->attributes

The plan is to make this feature local, include-based variables

e.g.

navigation.jade


nav.nav(class='nav-'.($vertical ? 'vertical' : 'horizontal')

index.jade


include navigation(vertical=false)
YamiOdymel commented 8 years ago

I have a thought about this,

maybe you can backup the variables before include the template,

and restore the variables back after included the template,

for example if we are going to include a foo template like this:

include foo(var1="val")

the compiled result might looks like this:

<?php backup(['var1' => $var1]); $var1 = "val"; ?>
<?php include 'foo'; ?>
<?php $var1 = restore('var1'); ?>

Just an idea for you to know :D

TorbenKoehn commented 8 years ago

Tale Jade doesn't use include since it would be a mess to handle. It's actually pretty easy to implement this, I just don't know if I even want/need it yet.

You basically can access any variable anyways, so

$var1 = 'val'
include foo

or even

$includeArgs(var1='val1' var2='val2')
include foo

would work just as well