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
e3eb1b76
Commit
e3eb1b76
authored
Jul 11, 2008
by
Seldaek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
+ Syntax: Static methods can be called using {Class::method()}
git-svn-id:
svn://dwoo.org/dwoo/trunk@122
0598d79b-80c4-4d41-97ba-ac86fbbd088b
parent
5fc48230
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
12 deletions
+27
-12
CHANGELOG
CHANGELOG
+4
-1
UPGRADE_NOTES
UPGRADE_NOTES
+1
-1
Compiler.php
lib/Dwoo/Compiler.php
+10
-10
CompilerTests.php
tests/CompilerTests.php
+12
-0
No files found.
CHANGELOG
View file @
e3eb1b76
...
...
@@ -4,10 +4,13 @@
{
if
$
foo
}>
{$
foo
}{$
bar
}{/}
-
This
also
allow
block
operations
such
as
:
{
a
http
://
url
.
com
;
"Text"
/}
which
equals
to
{
a
http
://
url
.
com
}
Text
{/}
+
Syntax
:
Block
plugins
that
you
want
to
call
without
content
can
be
self
-
closed
just
like
XML
tags
(
e
.
g
.
{
a
"http://url.com"
/}
)
self
-
closed
just
like
XML
tags
(
e
.
g
.
{
a
"http://url.com"
/}
).
Be
careful
not
to
close
a
non
-
block
plugin
like
that
however
,
since
it
will
close
it
's
parent block
+ Plugins: Added the {a} block plugin to generate <a> tags
+ API: Added Dwoo_Plugin::paramsToAttributes() utility function to help
with the creation of compilable xml/html-related plugins
+ Syntax: Static methods can be called using {Class::method()}
* Syntax: Math expressions in strings are now only allowed when the entire
expression is delimited, e.g. {"/$foo/$bar"} evaluates as just that while
{"/`$foo/$bar`"} will result in "/".($foo/$bar), therefore processing the /
...
...
UPGRADE_NOTES
View file @
e3eb1b76
-----------------------------------------------------------------------------
-- 0.9.2
--
Upgrading to Dwoo v
0.9.2
-----------------------------------------------------------------------------
1. Block plugins
...
...
lib/Dwoo/Compiler.php
View file @
e3eb1b76
...
...
@@ -1105,7 +1105,7 @@ class Dwoo_Compiler implements Dwoo_ICompiler
}
elseif
(
$first
===
'"'
||
$first
===
"'"
)
{
// string
$out
=
$this
->
parseString
(
$in
,
$from
,
$to
,
$parsingParams
,
$curBlock
,
$pointer
);
}
elseif
(
preg_match
(
'/^[a-z][a-z0-9_]*('
.
(
is_array
(
$parsingParams
)
||
$curBlock
!=
'root'
?
''
:
'\s+[^(]|'
)
.
'\s*\(|\s*'
.
$this
->
rdr
.
'|\s*;)/i'
,
$substr
))
{
}
elseif
(
preg_match
(
'/^[a-z][a-z0-9_]*(
?:::[a-z][a-z0-9_]*)?(
'
.
(
is_array
(
$parsingParams
)
||
$curBlock
!=
'root'
?
''
:
'\s+[^(]|'
)
.
'\s*\(|\s*'
.
$this
->
rdr
.
'|\s*;)/i'
,
$substr
))
{
// func
$out
=
$this
->
parseFunction
(
$in
,
$from
,
$to
,
$parsingParams
,
$curBlock
,
$pointer
);
}
elseif
(
$first
===
';'
)
{
...
...
@@ -1178,13 +1178,19 @@ class Dwoo_Compiler implements Dwoo_ICompiler
protected
function
parseFunction
(
$in
,
$from
,
$to
,
$parsingParams
=
false
,
$curBlock
=
''
,
&
$pointer
=
null
)
{
$cmdstr
=
substr
(
$in
,
$from
,
$to
-
$from
);
preg_match
(
'/^([a-z][a-z0-9_]*)(\s*'
.
$this
->
rdr
.
'|\s*;)?/i'
,
$cmdstr
,
$match
);
preg_match
(
'/^([a-z][a-z0-9_]*(?:::[a-z][a-z0-9_]*)?)(\s*'
.
$this
->
rdr
.
'|\s*;)?/i'
,
$cmdstr
,
$match
);
if
(
empty
(
$match
[
1
]))
{
throw
new
Dwoo_Compilation_Exception
(
$this
,
'Parse error, invalid function name'
);
}
$func
=
$match
[
1
];
if
(
!
empty
(
$match
[
2
]))
{
$cmdstr
=
$match
[
1
];
}
if
(
$this
->
debug
)
echo
'FUNC FOUND<br />'
;
if
(
$this
->
debug
)
echo
'FUNC FOUND
('
.
$func
.
')
<br />'
;
$paramsep
=
''
;
...
...
@@ -1210,18 +1216,12 @@ class Dwoo_Compiler implements Dwoo_ICompiler
$state
=
0
;
if
(
$paramspos
===
false
)
{
if
(
strpos
(
$cmdstr
,
' '
))
{
$func
=
substr
(
$cmdstr
,
0
,
strpos
(
$cmdstr
,
' '
));
}
else
{
$func
=
$cmdstr
;
}
$params
=
array
();
if
(
$curBlock
!==
'root'
)
{
return
$this
->
parseOthers
(
$in
,
$from
,
$to
,
$parsingParams
,
$curBlock
,
$pointer
);
}
}
else
{
$func
=
rtrim
(
substr
(
$cmdstr
,
0
,
$paramspos
));
$whitespace
=
strlen
(
substr
(
$cmdstr
,
strlen
(
$func
),
$paramspos
-
strlen
(
$func
)));
$paramstr
=
substr
(
$cmdstr
,
$paramspos
+
1
);
if
(
substr
(
$paramstr
,
-
1
,
1
)
===
$paramsep
)
{
...
...
@@ -1300,7 +1300,7 @@ class Dwoo_Compiler implements Dwoo_ICompiler
if
(
$this
->
debug
)
echo
'FUNC ADDS '
.
((
isset
(
$paramstr
)
?
strlen
(
$paramstr
)
:
0
)
+
(
')'
===
$paramsep
?
2
:
(
$paramspos
===
false
?
0
:
1
))
+
strlen
(
$func
))
.
' TO POINTER<br/>'
;
}
if
(
$curBlock
===
'method'
||
$func
===
'do'
)
{
if
(
$curBlock
===
'method'
||
$func
===
'do'
||
strstr
(
$func
,
'::'
)
!==
false
)
{
$pluginType
=
Dwoo
::
NATIVE_PLUGIN
;
}
else
{
$pluginType
=
$this
->
getPluginType
(
$func
);
...
...
tests/CompilerTests.php
View file @
e3eb1b76
...
...
@@ -527,6 +527,14 @@ replace="BAR"
$this
->
assertEquals
(
'a <?php echo "foo"; ?>'
,
$this
->
dwoo
->
get
(
$tpl
,
array
(
'foo'
=>
'a <?php echo "foo"; ?>'
),
$this
->
compiler
));
}
public
function
testStaticMethodCall
()
{
$tpl
=
new
Dwoo_Template_String
(
'{upper MethodCallsHelper::staticFoo(bar "baz")}'
);
$tpl
->
forceCompilation
();
$this
->
assertEquals
(
'-BAZBAR-'
,
$this
->
dwoo
->
get
(
$tpl
,
array
(),
$this
->
compiler
));
}
}
class
MethodCallsHelper
{
...
...
@@ -551,4 +559,8 @@ class MethodCallsHelper {
return
(
$int
+
5
)
.
$str
;
}
public
function
__toString
()
{
return
'obj'
;
}
public
static
function
staticFoo
(
$bar
,
$baz
)
{
return
"-
$baz$bar
-"
;
}
}
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