I am looking to generate a string like \usepackage{mypackage} from a Django template.
Suppose there is a variable package.name in the context how can I generate this?
Firstly I tried, \usepackage{{{package.name}}} but that throws TemplateSyntaxError
Then I tried \usepackage{ {{package.name}} } which works but has the two spaces in the output, ie, \usepackage{ mypackage }
Is there an easy way to generate this string with Django template engine?
CodePudding user response:
You can do something like this using span
\usepackage{<span>{{package.name}}</span>}
CodePudding user response:
one option is that you can write a template tag that will render it as you want and give the package name as a variable
