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
77501e61
Commit
77501e61
authored
Jun 27, 2008
by
Seldaek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
git-svn-id:
svn://dwoo.org/dwoo/trunk@103
0598d79b-80c4-4d41-97ba-ac86fbbd088b
parent
8d7eeff5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
23 deletions
+10
-23
strip.php
lib/plugins/builtin/blocks/strip.php
+3
-13
BlockTests.php
tests/BlockTests.php
+7
-10
No files found.
lib/plugins/builtin/blocks/strip.php
View file @
77501e61
...
@@ -21,7 +21,7 @@
...
@@ -21,7 +21,7 @@
*/
*/
class
Dwoo_Plugin_strip
extends
Dwoo_Block_Plugin
implements
Dwoo_ICompilable_Block
class
Dwoo_Plugin_strip
extends
Dwoo_Block_Plugin
implements
Dwoo_ICompilable_Block
{
{
public
function
init
(
$type
=
'text'
)
public
function
init
()
{
{
}
}
...
@@ -33,18 +33,8 @@ class Dwoo_Plugin_strip extends Dwoo_Block_Plugin implements Dwoo_ICompilable_Bl
...
@@ -33,18 +33,8 @@ class Dwoo_Plugin_strip extends Dwoo_Block_Plugin implements Dwoo_ICompilable_Bl
public
static
function
postProcessing
(
Dwoo_Compiler
$compiler
,
array
$params
,
$prepend
,
$append
,
$content
)
public
static
function
postProcessing
(
Dwoo_Compiler
$compiler
,
array
$params
,
$prepend
,
$append
,
$content
)
{
{
$params
=
$compiler
->
getCompiledParams
(
$params
);
$params
=
$compiler
->
getCompiledParams
(
$params
);
switch
(
trim
(
$params
[
'type'
],
'"\''
))
{
$content
=
preg_replace
(
array
(
"/
\n
/"
,
"/
\r
/"
,
'/(<\?(?:php)?|<%)\s*/'
),
array
(
''
,
''
,
'$1 '
),
preg_replace
(
'#^\s*(.+?)\s*$#m'
,
'$1'
,
$content
));
case
'code'
:
$content
=
preg_replace
(
'/\{[\r\n]+/'
,
'{ '
,
preg_replace
(
'#^\s*(.+?)\s*$#m'
,
'$1'
,
$content
));
$content
=
str_replace
(
array
(
"
\n
"
,
"
\r
"
),
null
,
$content
);
break
;
case
'text'
:
default
:
$content
=
str_replace
(
array
(
"
\n
"
,
"
\r
"
),
null
,
preg_replace
(
'#^\s*(.+?)\s*$#m'
,
'$1'
,
$content
));
}
return
$content
;
return
$content
;
}
}
...
...
tests/BlockTests.php
View file @
77501e61
...
@@ -18,7 +18,7 @@ class BlockTests extends PHPUnit_Framework_TestCase
...
@@ -18,7 +18,7 @@ class BlockTests extends PHPUnit_Framework_TestCase
{
{
$cmp
=
new
Dwoo_Compiler
();
$cmp
=
new
Dwoo_Compiler
();
$cmp
->
setAutoEscape
(
true
);
$cmp
->
setAutoEscape
(
true
);
$tpl
=
new
Dwoo_Template_String
(
'{$foo}{auto_escape off}{$foo}{/}'
);
$tpl
=
new
Dwoo_Template_String
(
'{$foo}{auto_escape off}{$foo}{/}'
);
$tpl
->
forceCompilation
();
$tpl
->
forceCompilation
();
...
@@ -28,7 +28,7 @@ class BlockTests extends PHPUnit_Framework_TestCase
...
@@ -28,7 +28,7 @@ class BlockTests extends PHPUnit_Framework_TestCase
$tpl
->
forceCompilation
();
$tpl
->
forceCompilation
();
$this
->
assertEquals
(
"a<b>ca<b>c"
,
$this
->
dwoo
->
get
(
$tpl
,
array
(
'foo'
=>
'a<b>c'
)));
$this
->
assertEquals
(
"a<b>ca<b>c"
,
$this
->
dwoo
->
get
(
$tpl
,
array
(
'foo'
=>
'a<b>c'
)));
// fixes the init call not being called (which is normal)
// fixes the init call not being called (which is normal)
$fixCall
=
new
Dwoo_Plugin_auto_escape
(
$this
->
dwoo
);
$fixCall
=
new
Dwoo_Plugin_auto_escape
(
$this
->
dwoo
);
$fixCall
->
init
(
''
);
$fixCall
->
init
(
''
);
...
@@ -61,7 +61,7 @@ class BlockTests extends PHPUnit_Framework_TestCase
...
@@ -61,7 +61,7 @@ class BlockTests extends PHPUnit_Framework_TestCase
$fixCall
=
new
Dwoo_Plugin_capture
(
$this
->
dwoo
);
$fixCall
=
new
Dwoo_Plugin_capture
(
$this
->
dwoo
);
$fixCall
->
init
(
''
);
$fixCall
->
init
(
''
);
}
}
public
function
testDynamic
()
public
function
testDynamic
()
{
{
$preTime
=
time
();
$preTime
=
time
();
...
@@ -69,7 +69,7 @@ class BlockTests extends PHPUnit_Framework_TestCase
...
@@ -69,7 +69,7 @@ class BlockTests extends PHPUnit_Framework_TestCase
$tpl
->
forceCompilation
();
$tpl
->
forceCompilation
();
$this
->
assertEquals
(
$preTime
.
$preTime
,
$this
->
dwoo
->
get
(
$tpl
,
array
(
'pre'
=>
$preTime
),
$this
->
compiler
));
$this
->
assertEquals
(
$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
(
$preTime
.
$postTime
,
$this
->
dwoo
->
get
(
$tpl
,
array
(
'pre'
=>
$postTime
),
$this
->
compiler
));
...
@@ -348,14 +348,11 @@ baz"));
...
@@ -348,14 +348,11 @@ baz"));
$this
->
assertEquals
(
"abca
\n
b
\n
c"
,
$this
->
dwoo
->
get
(
$tpl
,
array
(),
$this
->
compiler
));
$this
->
assertEquals
(
"abca
\n
b
\n
c"
,
$this
->
dwoo
->
get
(
$tpl
,
array
(),
$this
->
compiler
));
}
}
public
function
testStrip
Code
()
public
function
testStrip
WithPhp
()
{
{
$tpl
=
new
Dwoo_Template_String
(
"{strip code}
$tpl
=
new
Dwoo_Template_String
(
"
{
strip}a\nb{\$foo=\"\\n\"
}
{if
\$
foo}>
{
\$foo}<{/if}\nc{/strip
}
a
\n
b
\n
c"
);
function foo() {
x;
}"
);
$tpl
->
forceCompilation
();
$tpl
->
forceCompilation
();
$this
->
assertEquals
(
"
function foo() { x;}
"
,
$this
->
dwoo
->
get
(
$tpl
,
array
(),
$this
->
compiler
));
$this
->
assertEquals
(
"
ab>
\n
<ca
\n
b
\n
c
"
,
$this
->
dwoo
->
get
(
$tpl
,
array
(),
$this
->
compiler
));
}
}
public
function
testTextFormat
()
public
function
testTextFormat
()
...
...
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