mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-10 00:03:24 +00:00
Support field_name argument in honeypot jinja extension
This commit is contained in:
parent
58ff5b934a
commit
c7f8cdd098
@ -47,12 +47,23 @@ class HoneypotExtension(Extension):
|
|||||||
|
|
||||||
def parse(self, parser: Parser) -> nodes.Output:
|
def parse(self, parser: Parser) -> nodes.Output:
|
||||||
lineno = parser.stream.expect("name:render_honeypot_field").lineno
|
lineno = parser.stream.expect("name:render_honeypot_field").lineno
|
||||||
|
key = nodes.Name("render_honeypot_field", "load", lineno=lineno)
|
||||||
|
if parser.stream.current.type != "block_end":
|
||||||
|
field_name = parser.parse_expression()
|
||||||
|
else:
|
||||||
|
field_name = nodes.Const(None)
|
||||||
call = self.call_method(
|
call = self.call_method(
|
||||||
"_render",
|
"_render",
|
||||||
[nodes.Name("render_honeypot_field", "load", lineno=lineno)],
|
[key, field_name],
|
||||||
lineno=lineno,
|
lineno=lineno,
|
||||||
)
|
)
|
||||||
return nodes.Output([nodes.MarkSafe(call)])
|
return nodes.Output([nodes.MarkSafe(call)])
|
||||||
|
|
||||||
def _render(self, render_honeypot_field: Callable[[str | None], str]):
|
def _render(
|
||||||
return render_to_string("honeypot/honeypot_field.html", render_honeypot_field())
|
self,
|
||||||
|
render_honeypot_field: Callable[[str | None], str],
|
||||||
|
field_name: str | None = None,
|
||||||
|
):
|
||||||
|
return render_to_string(
|
||||||
|
"honeypot/honeypot_field.html", render_honeypot_field(field_name=field_name)
|
||||||
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user