-
Notifications
You must be signed in to change notification settings - Fork 67
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
DOC Document changes to template layer #591
DOC Document changes to template layer #591
Conversation
94d90fe
to
827cb70
Compare
a6f45e5
to
fd791b5
Compare
fd791b5
to
a23cf76
Compare
|
||
Just like in PHP, method names are case insensitive, but property names are case sensitive. | ||
|
||
Using `$MyValue` in a template will successfully call a `myValue()` method, or a `getMyvalue()` method even though the case doesn't match what you used in the template. But it *will not* match a `myValue` property or database field because the case doesn't match. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using `$MyValue` in a template will successfully call a `myValue()` method, or a `getMyvalue()` method even though the case doesn't match what you used in the template. But it *will not* match a `myValue` property or database field because the case doesn't match. | |
Using `$MyValue` in a template will successfully call a `myValue()` method, or a `getMyValue()` method even though the case doesn't match what you used in the template. But it *will not* match a `myValue` property or database field because the case doesn't match. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done (found an unrelated method with the same bad casing in php coding conventions which I also updated)
@@ -459,6 +459,62 @@ Note that the `SilverStripe\View\ViewableData` class has been renamed to [`Silve | |||
|
|||
See [many renamed classes](#renamed-classes) for more information about this change. | |||
|
|||
#### Improved separation between the view and model layers {#view-layer-separation} | |||
|
|||
Historically the `ModelData` class did double-duty as being the base class for most models as well as being the presumed class wrapping data for the template layer. Part of this included methods like `XML_val()` being called on any object in the template layer, despite being methods very specifically implemented on `ModelData`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Historically it's been called ViewableData
? Maybe mention that ModelData used to be called ViewableData
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Directly above this it says
Note that the
SilverStripe\View\ViewableData
class has been renamed toSilverStripe\Model\ModelData
. We will refer to it asModelData
in the rest of these change logs.
@@ -6,6 +6,9 @@ icon: code | |||
|
|||
# Rendering data to a template | |||
|
|||
> [!NOTE] | |||
> The template syntax, file extensions, and specifics about which tempaltes are chosen from a set as described on this page are specific to the default [`SSTemplateEngine`](api:SilverStripe\View\SSTemplateEngine) - but many of the concepts here (especially the PHP code) should work with any template engine you choose to use. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
> The template syntax, file extensions, and specifics about which tempaltes are chosen from a set as described on this page are specific to the default [`SSTemplateEngine`](api:SilverStripe\View\SSTemplateEngine) - but many of the concepts here (especially the PHP code) should work with any template engine you choose to use. | |
> The template syntax, file extensions, and specifics about which templates are chosen from a set as described on this page are specific to the default [`SSTemplateEngine`](api:SilverStripe\View\SSTemplateEngine) - but many of the concepts here (especially the PHP code) should work with any template engine you choose to use. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -194,5 +203,62 @@ class MyPageController extends PageController | |||
} | |||
``` | |||
|
|||
> [!WARNING] | |||
> A common mistake is trying to loop over an array directly in a template - this won't work. You'll need to wrap the array in some `ModelData` instance as mentioned above. | |||
Or wrap the data in a `ModelData` subclass: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or wrap the data in a `ModelData` subclass: | |
Or wrap the data in a `ModelData` subclass such as `ArrayList`: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, but said ArrayData
since that's what the example shows.
|
||
Every time a raw template file is processed, some PHP code is generated from it which is then executed to produce the final rendered result. | ||
|
||
That PHP code is stored in the filesystem so that the raw template file doesn't need to be processed again until either the cache is flushed or the raw template file is updated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That PHP code is stored in the filesystem so that the raw template file doesn't need to be processed again until either the cache is flushed or the raw template file is updated. | |
That PHP code is cached in the filesystem so that the raw template file doesn't need to be processed again until either the cache is flushed or the raw template file is updated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just ties it together a little better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
a23cf76
to
ecd38db
Compare
Issue