Compare commits

..

2 Commits

Author SHA1 Message Date
Guy Sartorelli
b150092395
Merge 25126267af into 6bb9a0b33d 2024-10-14 02:56:54 +00:00
Guy Sartorelli
25126267af
API Refactor template layer into its own module
Includes the following large-scale changes:
- Impoved barrier between model and view layers
- Improved casting of scalar to relevant DBField types
- Improved capabilities for rendering arbitrary data in templates
2024-10-14 15:56:44 +13:00
5 changed files with 13 additions and 17 deletions

View File

@ -46,7 +46,7 @@ class Email extends SymfonyEmail
private static string|array $admin_email = '';
/**
* The name of the HTML template to render the email with (without *.ss extension)
* The name of the HTML template to render the email with
*/
private string $HTMLTemplate = '';
@ -408,13 +408,11 @@ class Email extends SymfonyEmail
}
/**
* Set the template to render the email with
* Set the template to render the email with.
* Do not include a file extension unless you are referencing a full absolute file path.
*/
public function setHTMLTemplate(string $template): static
{
if (substr($template ?? '', -3) == '.ss') {
$template = substr($template ?? '', 0, -3);
}
$this->HTMLTemplate = $template;
return $this;
}
@ -428,13 +426,11 @@ class Email extends SymfonyEmail
}
/**
* Set the template to render the plain part with
* Set the template to render the plain part with.
* Do not include a file extension unless you are referencing a full absolute file path.
*/
public function setPlainTemplate(string $template): static
{
if (substr($template ?? '', -3) == '.ss') {
$template = substr($template ?? '', 0, -3);
}
$this->plainTemplate = $template;
return $this;
}

View File

@ -82,7 +82,7 @@ class Form extends ModelData implements HasRequestHandler
const ENC_TYPE_MULTIPART = 'multipart/form-data';
/**
* Accessed by Form.ss.
* Accessed by Form template.
* A performance enhancement over the generate-the-form-tag-and-then-remove-it code that was there previously
*
* @var bool
@ -159,7 +159,7 @@ class Form extends ModelData implements HasRequestHandler
/**
* Legend value, to be inserted into the
* <legend> element before the <fieldset>
* in Form.ss template.
* in Form template.
*
* @var string|null
*/
@ -888,7 +888,7 @@ class Form extends ModelData implements HasRequestHandler
/**
* Set the legend value to be inserted into
* the <legend> element in the Form.ss template.
* the <legend> element in the Form template.
* @param string $legend
* @return $this
*/
@ -1234,7 +1234,7 @@ class Form extends ModelData implements HasRequestHandler
/**
* Get the legend value to be inserted into the
* <legend> element in Form.ss
* <legend> element in Form template
*
* @return string
*/

View File

@ -948,7 +948,7 @@ class FormField extends RequestHandler
*
* The default field holder is a label and a form field inside a div.
*
* @see FieldHolder.ss
* see FieldHolder template
*
* @param array $properties
*

View File

@ -87,7 +87,7 @@ class SSViewer
private TemplateEngine $templateEngine;
/**
* @param string|array $templates If passed as a string with .ss extension, used as the "main" template.
* @param string|array $templates If passed as a string, used as the "main" template.
* If passed as an array, it can be used for template inheritance (first found template "wins").
* Usually the array values are PHP class names, which directly correlate to template names.
* <code>
@ -179,7 +179,7 @@ class SSViewer
$templates[] = $template;
$templates[] = ['type' => 'Includes', $template];
// If the class is "PageController" (PSR-2 compatibility) or "Page_Controller" (legacy), look for Page.ss
// If the class is "PageController" (PSR-2 compatibility) or "Page_Controller" (legacy), look for Page template
if (preg_match('/^(?<name>.+[^\\\\])_?Controller$/iU', $class ?? '', $matches)) {
$templates[] = $matches['name'] . $suffix;
}

View File

@ -308,7 +308,7 @@ class i18nTest extends SapphireTest
}
/**
* See @i18nTestModule.ss for the template that is being used for this test
* See i18nTestModule.ss for the template that is being used for this test
* */
public function testNewTemplateTranslation()
{