Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
doxverilog
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
doxverilog
Commits
425e64e2
Commit
425e64e2
authored
Mar 04, 2014
by
Dimitri van Heesch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extension specific filtering
parent
47adeb82
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
10 deletions
+30
-10
context.cpp
src/context.cpp
+2
-2
template.cpp
src/template.cpp
+27
-7
template.h
src/template.h
+1
-1
No files found.
src/context.cpp
View file @
425e64e2
...
...
@@ -6788,8 +6788,8 @@ void generateOutputViaTemplate()
g_globals
.
outputFormat
=
ContextGlobals
::
Html
;
g_globals
.
dynSectionId
=
0
;
g_globals
.
outputDir
=
Config_getString
(
"HTML_OUTPUT"
);
HtmlEscaper
e
sc
;
ctx
->
setEscapeIntf
(
&
e
sc
);
HtmlEscaper
htmlE
sc
;
ctx
->
setEscapeIntf
(
Config_getString
(
"HTML_FILE_EXTENSION"
),
&
htmlE
sc
);
HtmlSpaceless
spl
;
ctx
->
setSpacelessIntf
(
&
spl
);
ctx
->
setOutputDirectory
(
g_globals
.
outputDir
);
...
...
src/template.cpp
View file @
425e64e2
...
...
@@ -584,8 +584,17 @@ class TemplateContextImpl : public TemplateContext
const
TemplateVariant
*
getRef
(
const
QCString
&
name
)
const
;
void
setOutputDirectory
(
const
QCString
&
dir
)
{
m_outputDir
=
dir
;
}
void
setEscapeIntf
(
TemplateEscapeIntf
*
intf
)
{
m_escapeIntf
=
intf
;
}
void
setEscapeIntf
(
const
QCString
&
ext
,
TemplateEscapeIntf
*
intf
)
{
int
i
=
(
!
ext
.
isEmpty
()
&&
ext
.
at
(
0
)
==
'.'
)
?
1
:
0
;
m_escapeIntfDict
.
insert
(
ext
.
mid
(
i
),
new
TemplateEscapeIntf
*
(
intf
));
}
void
selectEscapeIntf
(
const
QCString
&
ext
)
{
TemplateEscapeIntf
**
ppIntf
=
m_escapeIntfDict
.
find
(
ext
);
m_activeEscapeIntf
=
ppIntf
?
*
ppIntf
:
0
;
}
void
setActiveEscapeIntf
(
TemplateEscapeIntf
*
intf
)
{
m_activeEscapeIntf
=
intf
;
}
void
setSpacelessIntf
(
TemplateSpacelessIntf
*
intf
)
{
m_spacelessIntf
=
intf
;
}
...
...
@@ -597,7 +606,7 @@ class TemplateContextImpl : public TemplateContext
QCString
templateName
()
const
{
return
m_templateName
;
}
int
line
()
const
{
return
m_line
;
}
QCString
outputDirectory
()
const
{
return
m_outputDir
;
}
TemplateEscapeIntf
*
escapeIntf
()
const
{
return
m_
e
scapeIntf
;
}
TemplateEscapeIntf
*
escapeIntf
()
const
{
return
m_
activeE
scapeIntf
;
}
TemplateSpacelessIntf
*
spacelessIntf
()
const
{
return
m_spacelessIntf
;
}
void
enableSpaceless
(
bool
b
)
{
m_spacelessEnabled
=
b
;
}
bool
spacelessEnabled
()
const
{
return
m_spacelessEnabled
&&
m_spacelessIntf
;
}
...
...
@@ -610,7 +619,8 @@ class TemplateContextImpl : public TemplateContext
QCString
m_outputDir
;
QList
<
QDict
<
TemplateVariant
>
>
m_contextStack
;
TemplateBlockContext
m_blockContext
;
TemplateEscapeIntf
*
m_escapeIntf
;
QDict
<
TemplateEscapeIntf
*>
m_escapeIntfDict
;
TemplateEscapeIntf
*
m_activeEscapeIntf
;
TemplateSpacelessIntf
*
m_spacelessIntf
;
bool
m_spacelessEnabled
;
};
...
...
@@ -1763,10 +1773,11 @@ class TemplateImpl : public TemplateNode, public Template
TemplateContextImpl
::
TemplateContextImpl
(
const
TemplateEngine
*
e
)
:
m_engine
(
e
),
m_templateName
(
"<unknown>"
),
m_line
(
1
),
m_
e
scapeIntf
(
0
),
:
m_engine
(
e
),
m_templateName
(
"<unknown>"
),
m_line
(
1
),
m_
activeE
scapeIntf
(
0
),
m_spacelessIntf
(
0
),
m_spacelessEnabled
(
FALSE
)
{
m_contextStack
.
setAutoDelete
(
TRUE
);
m_escapeIntfDict
.
setAutoDelete
(
TRUE
);
push
();
}
...
...
@@ -2510,13 +2521,13 @@ class TemplateNodeMsg : public TemplateNodeCreator<TemplateNodeMsg>
TemplateContextImpl
*
ci
=
dynamic_cast
<
TemplateContextImpl
*>
(
c
);
ci
->
setLocation
(
m_templateName
,
m_line
);
TemplateEscapeIntf
*
escIntf
=
ci
->
escapeIntf
();
ci
->
setEscapeIntf
(
0
);
// avoid escaping things we send to standard out
ci
->
set
Active
EscapeIntf
(
0
);
// avoid escaping things we send to standard out
bool
enable
=
ci
->
spacelessEnabled
();
ci
->
enableSpaceless
(
FALSE
);
FTextStream
ts
(
stdout
);
m_nodes
.
render
(
ts
,
c
);
ts
<<
endl
;
ci
->
setEscapeIntf
(
escIntf
);
ci
->
set
Active
EscapeIntf
(
escIntf
);
ci
->
enableSpaceless
(
enable
);
}
private
:
...
...
@@ -2809,6 +2820,12 @@ class TemplateNodeCreate : public TemplateNodeCreator<TemplateNodeCreate>
TemplateImpl
*
createTemplate
=
ct
?
dynamic_cast
<
TemplateImpl
*>
(
ct
)
:
0
;
if
(
createTemplate
)
{
QCString
extension
=
outputFile
;
int
i
=
extension
.
findRev
(
'.'
);
if
(
i
!=-
1
)
{
extension
=
extension
.
right
(
extension
.
length
()
-
i
-
1
);
}
if
(
!
ci
->
outputDirectory
().
isEmpty
())
{
outputFile
.
prepend
(
ci
->
outputDirectory
()
+
"/"
);
...
...
@@ -2816,9 +2833,12 @@ class TemplateNodeCreate : public TemplateNodeCreator<TemplateNodeCreate>
QFile
f
(
outputFile
);
if
(
f
.
open
(
IO_WriteOnly
))
{
TemplateEscapeIntf
*
escIntf
=
ci
->
escapeIntf
();
ci
->
selectEscapeIntf
(
extension
);
FTextStream
ts
(
&
f
);
createTemplate
->
render
(
ts
,
c
);
t
->
engine
()
->
unload
(
t
);
ci
->
setActiveEscapeIntf
(
escIntf
);
}
else
{
...
...
src/template.h
View file @
425e64e2
...
...
@@ -399,7 +399,7 @@ class TemplateContext
/** Sets the interface that will be used for escaping the result
* of variable expansion before writing it to the output.
*/
virtual
void
setEscapeIntf
(
TemplateEscapeIntf
*
intf
)
=
0
;
virtual
void
setEscapeIntf
(
const
QCString
&
extension
,
TemplateEscapeIntf
*
intf
)
=
0
;
/** Sets the interface that will be used inside a spaceless block
* to remove any redundant whitespace.
...
...
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