-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nested Components #41
Comments
I've been looking into this and using the It seems to be improved somewhat by changing private static function handleChildHTML($data, $properties, $parser)
{
if (isset($data['Children']['php'])) {
// handle children property collision
if (isset($properties['children'])) {
throw new SSTemplateParseException('Cannot use "children" as a property name and have inner HTML.', $parser);
}
// construct php
$value = $data['Children']['php'];
$php = "\$_props['children'] = '';\n";
$php = str_replace("\$_props = array();\n", "", $php);
$php = str_replace("unset(\$_props);\n", "", $php);
$valAppend = "\$val .=";
if(strpos($value, $valAppend) !== false) {
// replace only the last
$php .= substr_replace($value, "\$_props['children'] .=", strrpos($php, $valAppend), strlen($valAppend));
}
$php .= "\$_props['children'] = SilverStripe\ORM\FieldType\DBField::create_field('HTMLText', \$_props['children']);\n";
return $php;
}
return '';
} This seems to fix the textNodes in my test cases. However the row and container are still printed afterwards, without the correct nesting. And now it's not printing the The new input now looks like this,
and the new output looks like, <div class="g-flex-col g-flex-col-xs-4 g-flex-col-sm-4 g-flex-col-md-4 g-flex-col-lg-4">
column1
</div>
<div class="g-flex-col g-flex-col-xs-8 g-flex-col-sm-8 g-flex-col-md-8 g-flex-col-lg-8">
column22
</div>
<div class="g-flex-row">
</div>
<div class="">
</div> |
@JoshuaCarter any ideas here? |
Hi I see that #39 had a fix for children / nested components, has that been released yet?
I'm just testing this code and I've found that it produces odd HTML where certain sections are repeated.
With this usage,
And these templates:
FlexContainer.ss
FlexRow.ss
FlexColumn.ss
I get HTML with incorrect textNodes and nesting of
Or does this render correctly for you with these templates?
Also, will fix #39 be published for SilverStripe 3 and 4?
Thanks
The text was updated successfully, but these errors were encountered: