Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
Dwoo
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Common
Dwoo
Commits
173da605
Commit
173da605
authored
Jan 21, 2011
by
Jordi Boggiano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed regression in 07e1dd
parent
39d9ca00
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
23 deletions
+40
-23
dynamic.php
lib/plugins/builtin/blocks/dynamic.php
+20
-20
BlockTests.php
tests/BlockTests.php
+20
-3
No files found.
lib/plugins/builtin/blocks/dynamic.php
View file @
173da605
...
@@ -29,28 +29,28 @@ class Dwoo_Plugin_dynamic extends Dwoo_Block_Plugin implements Dwoo_ICompilable_
...
@@ -29,28 +29,28 @@ class Dwoo_Plugin_dynamic extends Dwoo_Block_Plugin implements Dwoo_ICompilable_
{
{
try
{
try
{
$compiler
->
findBlock
(
'dynamic'
);
$compiler
->
findBlock
(
'dynamic'
);
$output
=
Dwoo_Compiler
::
PHP_OPEN
.
'if($doCache) {'
.
"
\n\t
"
.
'echo \'<dwoo:dynamic_\'.$dynamicId.\'>'
.
str_replace
(
'\''
,
'\\\''
,
$content
)
.
'</dwoo:dynamic_\'.$dynamicId.\'>\';'
.
"
\n
} else {\n
\t
"
;
if
(
substr
(
$content
,
0
,
strlen
(
Dwoo_Compiler
::
PHP_OPEN
))
==
Dwoo_Compiler
::
PHP_OPEN
)
{
$output
.=
substr
(
$content
,
strlen
(
Dwoo_Compiler
::
PHP_OPEN
));
}
else
{
$output
.=
Dwoo_Compiler
::
PHP_CLOSE
.
$content
;
}
if
(
substr
(
$output
,
-
strlen
(
Dwoo_Compiler
::
PHP_CLOSE
))
==
Dwoo_Compiler
::
PHP_CLOSE
)
{
$output
=
substr
(
$output
,
0
,
-
strlen
(
Dwoo_Compiler
::
PHP_CLOSE
));
}
else
{
$output
.=
Dwoo_Compiler
::
PHP_OPEN
;
}
$output
.=
"
\n
}"
.
Dwoo_Compiler
::
PHP_CLOSE
;
return
$output
;
}
catch
(
Dwoo_Compilation_Exception
$e
)
{
return
$content
;
return
$content
;
}
catch
(
Dwoo_Compilation_Exception
$e
)
{
}
}
$output
=
Dwoo_Compiler
::
PHP_OPEN
.
'if($doCache) {'
.
"
\n\t
"
.
'echo \'<dwoo:dynamic_\'.$dynamicId.\'>'
.
str_replace
(
'\''
,
'\\\''
,
$content
)
.
'</dwoo:dynamic_\'.$dynamicId.\'>\';'
.
"
\n
} else {\n
\t
"
;
if
(
substr
(
$content
,
0
,
strlen
(
Dwoo_Compiler
::
PHP_OPEN
))
==
Dwoo_Compiler
::
PHP_OPEN
)
{
$output
.=
substr
(
$content
,
strlen
(
Dwoo_Compiler
::
PHP_OPEN
));
}
else
{
$output
.=
Dwoo_Compiler
::
PHP_CLOSE
.
$content
;
}
if
(
substr
(
$output
,
-
strlen
(
Dwoo_Compiler
::
PHP_CLOSE
))
==
Dwoo_Compiler
::
PHP_CLOSE
)
{
$output
=
substr
(
$output
,
0
,
-
strlen
(
Dwoo_Compiler
::
PHP_CLOSE
));
}
else
{
$output
.=
Dwoo_Compiler
::
PHP_OPEN
;
}
$output
.=
"
\n
}"
.
Dwoo_Compiler
::
PHP_CLOSE
;
return
$output
;
}
}
public
static
function
unescape
(
$output
,
$dynamicId
,
$compiledFile
)
public
static
function
unescape
(
$output
,
$dynamicId
,
$compiledFile
)
...
...
tests/BlockTests.php
View file @
173da605
...
@@ -103,14 +103,31 @@ BAZZ {/capture}{$foo}');
...
@@ -103,14 +103,31 @@ BAZZ {/capture}{$foo}');
public
function
testDynamic
()
public
function
testDynamic
()
{
{
$preTime
=
time
();
$preTime
=
time
();
$tpl
=
new
Dwoo_Template_String
(
'{$pre}{dynamic}{$pre}{/}'
,
10
,
'testDynamic'
);
$tpl
=
new
Dwoo_Template_String
(
'
t
{$pre}{dynamic}{$pre}{/}'
,
10
,
'testDynamic'
);
$tpl
->
forceCompilation
();
$tpl
->
forceCompilation
();
$this
->
assertEquals
(
$preTime
.
$preTime
,
$this
->
dwoo
->
get
(
$tpl
,
array
(
'pre'
=>
$preTime
),
$this
->
compiler
));
$this
->
assertEquals
(
't'
.
$preTime
.
$preTime
,
$this
->
dwoo
->
get
(
$tpl
,
array
(
'pre'
=>
$preTime
),
$this
->
compiler
));
sleep
(
1
);
sleep
(
1
);
$postTime
=
time
();
$postTime
=
time
();
$this
->
assertEquals
(
$preTime
.
$postTime
,
$this
->
dwoo
->
get
(
$tpl
,
array
(
'pre'
=>
$postTime
),
$this
->
compiler
));
$this
->
assertEquals
(
't'
.
$preTime
.
$postTime
,
$this
->
dwoo
->
get
(
$tpl
,
array
(
'pre'
=>
$postTime
),
$this
->
compiler
));
// fixes the init call not being called (which is normal)
$fixCall
=
new
Dwoo_Plugin_dynamic
(
$this
->
dwoo
);
$fixCall
->
init
(
''
);
}
public
function
testDynamicNested
()
{
$preTime
=
time
();
$tpl
=
new
Dwoo_Template_String
(
't{$pre}{dynamic}{$pre}{dynamic}{$pre}{/}{/}'
,
10
,
'testDynamicNested'
);
$tpl
->
forceCompilation
();
$this
->
assertEquals
(
't'
.
$preTime
.
$preTime
.
$preTime
,
$this
->
dwoo
->
get
(
$tpl
,
array
(
'pre'
=>
$preTime
),
$this
->
compiler
));
sleep
(
1
);
$postTime
=
time
();
$this
->
assertEquals
(
't'
.
$preTime
.
$postTime
.
$postTime
,
$this
->
dwoo
->
get
(
$tpl
,
array
(
'pre'
=>
$postTime
),
$this
->
compiler
));
// fixes the init call not being called (which is normal)
// fixes the init call not being called (which is normal)
$fixCall
=
new
Dwoo_Plugin_dynamic
(
$this
->
dwoo
);
$fixCall
=
new
Dwoo_Plugin_dynamic
(
$this
->
dwoo
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment