mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-07 18:51:41 +09:00
Add deprecation warnings if syntax like <--#include-->, <!--%import--> is used in template v2
This commit is contained in:
parent
6a2a2826ec
commit
c42d059594
2 changed files with 15 additions and 0 deletions
|
|
@ -932,6 +932,11 @@ class TemplateParser_v2
|
||||||
*/
|
*/
|
||||||
protected function _addDeprecationMessages(string $content): string
|
protected function _addDeprecationMessages(string $content): string
|
||||||
{
|
{
|
||||||
|
// <!--#include-->, <!--%import-->, etc.
|
||||||
|
$content = preg_replace_callback('#<!--(\#include|%import|%unload|%load_js_plugin)\s?\(.+?-->#', function($match) {
|
||||||
|
return '<?php trigger_error("' . $match[1] . ' is not supported in template v2", \E_USER_WARNING); ?>';
|
||||||
|
}, $content);
|
||||||
|
|
||||||
// <block>
|
// <block>
|
||||||
$content = preg_replace_callback('#<block(?=\s)#', function($match) {
|
$content = preg_replace_callback('#<block(?=\s)#', function($match) {
|
||||||
return $match[0] . '<?php trigger_error("block element is not supported in template v2", \E_USER_WARNING); ?>';
|
return $match[0] . '<?php trigger_error("block element is not supported in template v2", \E_USER_WARNING); ?>';
|
||||||
|
|
|
||||||
|
|
@ -1059,6 +1059,16 @@ class TemplateParserV2Test extends \Codeception\Test\Unit
|
||||||
|
|
||||||
public function testDeprecationMessages()
|
public function testDeprecationMessages()
|
||||||
{
|
{
|
||||||
|
// <!--#include()-->
|
||||||
|
$source = '<!--#include("foo.html")-->';
|
||||||
|
$target = '<?php trigger_error("#include is not supported in template v2", \E_USER_WARNING); ?>';
|
||||||
|
$this->assertEquals($target, $this->_parse($source));
|
||||||
|
|
||||||
|
// <!--%import()-->
|
||||||
|
$source = '<!--%import("../foo/bar.js")-->';
|
||||||
|
$target = '<?php trigger_error("%import is not supported in template v2", \E_USER_WARNING); ?>';
|
||||||
|
$this->assertEquals($target, $this->_parse($source));
|
||||||
|
|
||||||
// <block> element
|
// <block> element
|
||||||
$source = '<block class="foobar">';
|
$source = '<block class="foobar">';
|
||||||
$target = '<block<?php trigger_error("block element is not supported in template v2", \E_USER_WARNING); ?> class="foobar">';
|
$target = '<block<?php trigger_error("block element is not supported in template v2", \E_USER_WARNING); ?> class="foobar">';
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue