Level-2 / Transphporm

Transformation Style Sheets - Revolutionising PHP templating
276 stars 27 forks source link

included templates doesn't get wrapped in <template> #25

Closed hobbeshunter closed 8 years ago

hobbeshunter commented 8 years ago

Hi,

I did something like this:

I had a main html file with an empty <head> tag, which I then filled with

head {
  content: template("includes/Admin\Head.html");
}

Admin\Head.html was just the usual stuff like

<meta charset="utf-8" />
<title>Title</title>

Then I got a warning:

Warning:  DOMDocument::loadXML(): Extra content at the end of the document in Entity

Which is quite logic, as the DOMDocument couldn't find a root element. Usually transphporm wraps xml in a <template> tag, but not xml from a file as it looks in Builder.php:35

$template = new Template($this->isFile ? $this->template : '<template>' . $this->template . '</template>');

I'm not sure if this is wanted behaviour.

Cheers, Martin

smolinari commented 8 years ago

I believe any file content should be wrapped in a <template> tag. Like so:

header.xml

<?xml version="1.0"?>
<template>
    <meta charset="utf-8" />
    <title>Title</title>
</template>

Scott

TRPB commented 8 years ago

This needs updating, the problem initially is that

<meta charset="utf-8" />
    <title>Title</title>

On its own is not valid XML. The rule needs to be either the template needs to be a valid XML file (with a root element) or it needs to be wrapped in