Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FFS Gluon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
firmware
FFS Gluon
Commits
dd23a805
Unverified
Commit
dd23a805
authored
7 years ago
by
Matthias Schiffer
Browse files
Options
Downloads
Patches
Plain Diff
gluon-web: add new <%| tag for escaped expressions
parent
961c9db8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
package/gluon-web/src/template_parser.c
+28
-13
28 additions, 13 deletions
package/gluon-web/src/template_parser.c
with
28 additions
and
13 deletions
package/gluon-web/src/template_parser.c
+
28
−
13
View file @
dd23a805
...
...
@@ -35,22 +35,24 @@
#include
<unistd.h>
/* code types */
#define T_TYPE_INIT 0
#define T_TYPE_TEXT 1
#define T_TYPE_COMMENT 2
#define T_TYPE_EXPR 3
#define T_TYPE_INCLUDE 4
#define T_TYPE_I18N 5
#define T_TYPE_I18N_RAW 6
#define T_TYPE_CODE 7
#define T_TYPE_EOF 8
typedef
enum
{
T_TYPE_INIT
,
T_TYPE_TEXT
,
T_TYPE_COMMENT
,
T_TYPE_EXPR
,
T_TYPE_EXPR_RAW
,
T_TYPE_INCLUDE
,
T_TYPE_I18N
,
T_TYPE_I18N_RAW
,
T_TYPE_CODE
,
T_TYPE_EOF
,
}
t_type_t
;
struct
template_chunk
{
const
char
*
s
;
const
char
*
e
;
in
t
type
;
t_type_
t
type
;
int
line
;
};
...
...
@@ -75,7 +77,8 @@ static const char *const gen_code[][2] = {
[
T_TYPE_INIT
]
=
{
NULL
,
NULL
},
[
T_TYPE_TEXT
]
=
{
"write('"
,
"')"
},
[
T_TYPE_COMMENT
]
=
{
NULL
,
NULL
},
[
T_TYPE_EXPR
]
=
{
"write(tostring("
,
" or ''))"
},
[
T_TYPE_EXPR
]
=
{
"write(pcdata(tostring("
,
" or '')))"
},
[
T_TYPE_EXPR_RAW
]
=
{
"write(tostring("
,
" or ''))"
},
[
T_TYPE_INCLUDE
]
=
{
"include('"
,
"')"
},
[
T_TYPE_I18N
]
=
{
"write(pcdata(translate('"
,
"')))"
},
[
T_TYPE_I18N_RAW
]
=
{
"write(translate('"
,
"'))"
},
...
...
@@ -226,11 +229,17 @@ static void template_code(struct template_parser *parser, const char *e)
break
;
/* expr */
case
'
=
'
:
case
'
|
'
:
s
++
;
parser
->
cur_chunk
.
type
=
T_TYPE_EXPR
;
break
;
/* expr raw */
case
'='
:
s
++
;
parser
->
cur_chunk
.
type
=
T_TYPE_EXPR_RAW
;
break
;
/* code */
default:
parser
->
cur_chunk
.
type
=
T_TYPE_CODE
;
...
...
@@ -295,6 +304,7 @@ static struct template_buffer * template_format_chunk(struct template_parser *pa
break
;
case
T_TYPE_EXPR
:
case
T_TYPE_EXPR_RAW
:
buf_append
(
buf
,
c
->
s
,
c
->
e
-
c
->
s
);
for
(
p
=
c
->
s
;
p
<
c
->
e
;
p
++
)
parser
->
line
+=
(
*
p
==
'\n'
);
...
...
@@ -305,6 +315,11 @@ static struct template_buffer * template_format_chunk(struct template_parser *pa
for
(
p
=
c
->
s
;
p
<
c
->
e
;
p
++
)
parser
->
line
+=
(
*
p
==
'\n'
);
break
;
case
T_TYPE_INIT
:
case
T_TYPE_COMMENT
:
case
T_TYPE_EOF
:
break
;
}
if
((
tail
=
gen_code
[
c
->
type
][
1
])
!=
NULL
)
...
...
This diff is collapsed.
Click to expand it.
Nico
@nrb
mentioned in commit
eb46e5a9
·
5 years ago
mentioned in commit
eb46e5a9
mentioned in commit eb46e5a9f124d7da98a225d248f6b4927768bf5f
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment