-
Notifications
You must be signed in to change notification settings - Fork 27
Importing tss files
Chris Johnson edited this page Aug 3, 2018
·
6 revisions
Like CSS, Transphporm supports @import 'filename';
You can store common display logic in one place and include it in another TSS file.
For example, you can write a TSS file that re-populates form data from post using:
form textarea {content: data(attr(name))}
form input[type="text"]:attr(value) {content: data(attr(name))}
If you store this in form.tss
you can import it in another TSS file using the code:
@import 'form.tss';
imported.tss
h1 {content: "From imported tss"}
$xml = '
<h1> </h1>
<div> </div>
';
$tss = "
@import 'imported.tss';
div {content: 'From main tss'}
";
$template = new \Transphporm\Builder($xml, $tss);
echo $template->output()->body;
Output:
<h1>From imported tss</h1>
<div>From main tss</div>
For information on how this works, see the section on populating forms.