ErlyDTL has an option auto_escape (which is set to true by default), which makes sure that all variables are escaped during rendering of the template.
Is there a way not to escape a specific variable?
Just found out this can be done with a safe filter. Like this:
{{var|safe}}
More information: https://docs.djangoproject.com/en/1.9/ref/templates/builtins/#safe
Related
I want to set vim plugin options that have the vimscript format let some#option = option inside my NeoVim init.lua file, but I can't figure out how to set these options in a format that NeoVim respects.
I've tried using vim.cmd("let some#option = option") but this doesn't seem to work. Any advice? Thanks!
From nanotee/nvim-lua-guide, the section on Managing vim internal variables shows various API calls, including
Global variables (g:):
vim.api.nvim_set_var()
vim.api.nvim_get_var()
vim.api.nvim_del_var()
In practice, setting a global variable looks like
vim.api.nvim_set_var('some#var', 'value')
You can also use the meta-accessors, such as vim.g:
vim.g['some#var'] = 'value'
The method with vmd.cmd can work, although using the more structured API shown above is advised.
Note that in vim.cmd("let some#option = option") the right-hand side of the assignment operator is an expression. This means the plain token option would be evaluated as an identifier.
Depending on what you are trying to do, you may need to add additional quotes to create a string.
vim.cmd("let some#var = 'value'")
I have a following situation: in some of my i18n property files there are properties containing a special word:
prop.example=specialword just for example
prop.test=just for test specialword
I want to have a possibility of having a property somewhere in my Config.groovy that would contain a specific value for this specialword so that if I specify:
specialword=Value of special word
in a Config.groovy then I want my i18n properties to be resolved like:
prop.example=Value of special word just for example
prop.test=just for test Value of special word
for that purpose, when building the project, I want to access property files in order to look for occurences of specialword and to replace them with value of specialwordvalue from Config.groovy.
Is that possible somehow? Perhaps, someone faced similar situation? I would really appreciate any help.
Thanks, Cheers
Instead of trying to change the way the properties are compiled, you would be better off passing the special value as an argument to your message code (as discussed in the comments to your question).
For instance:
<g:message code="my.key.code" args="[someVariableWithAValueFromConfig]" />
If your message code doesn't use the argument it will simply be ignored. This seems like the best approach to the problem you are trying to solve.
I am using Swig as the template engine in my project to create XML.
To make the XML output look nice I need to add a "-" everytime I use the template functions ({% -%}, {{ -}}, {# -#}).
It would be nice to be able to change the default behavior to always strip whitespace before and after. Is there a setting for this already?
No, there isn't.
The stripping is done in line 624 in parser.js:
https://github.com/paularmstrong/swig/blob/2e0e135ac04da5bf75f79cf8d4498094b3b49d35/lib/parser.js#L624
The variables stripNext and stripPrev are set to true only if a tag or a variable expression includes this -. If not stripping will not be done. There is no other way.
I would like to globally prevent LaTeX from hyphenating 'Objective-C'. I am aware of the \hyphenation command, but I don't see how I can make use of it. If I pass 'Objective-C' to this command, the dash will be treated as a hint to hyphenate the word there.
One solution I found is wrapping Objective-C into an mbox each time I use it. However, the document I am writing contains this name a lot, and wrapping it into an mbox each time is ugly (as is defining a command and using this over and over again in the source code).
Why is defining a new command ugly? It's how \LaTeX\ defines itself.
\def\ObjectiveC{\mbox{Objective-C}}
Use \nobreakdash. That's what LyX produces when I insert a nonbreakingdash and convert it to tex.
As suggested here, you could define a command like this:
\newcommand\dash{\nobreakdash-\hspace{0pt}}
and use it like this
Consider the $n$\dash dimensional manifold ...
Also, you could use the babel package and use "~ as a protected hyphen. I'm not sure if using babel is advisable when writing in english, though.
Pursuant to this question:
Redefining Commands in a New Environment
How does one redefine (or define using \def) a macro that uses parameters? I keep getting an illegal parameter definition in \foo error. Since I require custom delimiters, I can't use \newcommand or \renewcommand.
A general form of my code looks like this:
\newenvironment{foo}{%
...spacing stuff and counter defs...
\def\fooitem#1. #2\endfooitem{%
...stuff...
}
\def\endfooitem{endfoo}
}
{...after material (spacing)...}
This must be possible. Right now I'm using plain-TeX definitions (as I mentioned in the question above) but I'd really like to be consistent with the LaTeX system.
You need to double the # characters for every nested definition. Internally, a \newcommand or a \newenvironment is calling \def.
\newenvironment{foo}{%
...
\def\fooitem##1. ##2\endfooitem{%
...
Besides that, this is the way to do what you're trying to do; there is no pure-LaTeX method to define a macro with delimited arguments.