I know that state.show_sls renders and display a state.
I would like to know how to render a template file that is used inside a state and display its content without needing to apply the state.
Is there a way to use the salt's jinja renderer from the command line to do that?
After some research I have come to the command salt.module.cp and it goes like this:
salt-call cp.get_template salt://file.jinja /dev/stdout
It renders a file as a template and prints it on the terminal.
I use it a lot while developing formulas to check my templates.
Related
I've been stuck on this for an embarrassingly long time. I have two inputs that aren't displaying correctly, a markdown widget and the list widget. They both appear as one long string. I thought I needed to add a markdown parser for the former at least so I'm using markdown-it in a manner similar to this:
https://github.com/11ty/eleventy/issues/236
It is adding paragraph breaks where they should be but they show up on the page as p tags. I thought this was because I already had the parsed text nested between p tags but if I delete those nothing shows up at all. When I look at the html file created by eleventy, the tags show up as "< ;p> ;" (without the spaces) which it seems the browser isn't reading correctly when trying to interpret the html. I'm using nunjucks for templating if that matters. My .eleventy.js file looks like this currently. What am I missing? Also the markdown filter seems to only want to take a string so I'm not sure where to even begin with the list.
By default, Nunjucks HTML-escapes all variables when outputting templates. This is what you want most of the time, unless you're trying to render HTML input.
You might want to try using the safe filter after your markdownify filter.
{{ markdownContent | markdownify | safe }}
I am trying to display multiple links in a single modal box on onclick function like this
$cgi->img({ -src =>'/images/question.png',
-width=>10,
-border=>0,
-height=>10,
-alt=>'Redirect Link',
-onClick=>"image_click()"
}
),$cgi->div({-id="modal1",-class=>"modal"},$cgi->div({-class=>"modal2"},$cgi->span({-class=>"close",-onclick=>span_click()"},'×'),$cgi->p({},$links),),)
It's working fine when I want to display a single link but if I want to display multiple links in the same box.I wasn't able to get it.Instead I am getting the text of it.
My links looks something like this
my $links="'select a link',\$cgi->a({-href=>somelink},'LINK1'),\$cgi->a({-href=>somelink},'LINK2');
What am I doing wrong?
In this line:
my $links="'select a link',\$cgi->a({-href=>somelink},'LINK1'),\$cgi->a({-href=>somelink},'LINK2');
$cgi->a(...) is a method call, you have it in a double quoted string, but you can't interpolate method calls in a double quoted string.
Try something like this instead:
my #links = 'select a link', $cgi->a({-href=>somelink},'LINK1'), ...
Which creates an array of things rather than trying to put all the things in a string. Then change
$cgi->p({}, $links)
to:
$cgi->p({}, #links)
I haven't tested this - sorry.
Just because you're using CGI doesn't mean you have to use the CGI methods for generating HTML. I would strongly recommend looking at using a templating module like Template::Toolkit, or a framework like Mojolicious which can be run from CGI and includes a templating system (and has next to no dependencies).
I want to make a template which automatically adds the name of person who used it in another page.
For example if I had the following template named "addedby":
Added by '~~~~'.
I want it so when I use it in the page like this:
This page was {{addedby}}
The ~~~~ is automatically replaced by the name of the user who used the template.
For example if user 'john' used the template the final page above would look like this:
This page was Added by 'john'.
Is this possible? I tried using ~~~~ but when I save the template ~~~~ is replaced directly in the template when I save it, not when I use the template in any of the pages.
It's impossible in a unsubstituted template. You could use the {{REVISIONUSER}} magic variable, but it always shows the user who made the last edit to the page not the one who added the template. You must in some way put the user name inside the page markup.
So you can either use a parameter to your template:
Added by '{{{1}}}'.
This page was {{addedby|~~~}}
or you use substitution and the trick from Template:4~ for inserting the username:
Added by '~~<noinclude></noinclude>~'.
This page was {{subst:addedby}}
(you can also make show a warning when used without subst:)
I don't think there is a particular extension for that currently. The closest to that I can recommend is https://www.mediawiki.org/wiki/Extension:LastModified
I was, until now, unable to find or create a good component to print the result of a TDBGrid, so what I did was to create a couple of for ... do and then save the result in a text file and opened right after with Notepad, so the user could print or save from there. Pretty ugly, right?
Now it just came to me that I could use those loops to create HTML code instead, which is more presentable. But how can I use, for example a TWebBrowser or something else to show that result instead of the TDBGrid approach?
And how can I print this HTML (with or without the TWebBrowser, as for example if I still use the TDBGrid to show the report and the HTML approach just if the user wants to print it)?
You can use either
TWebBrowser printing abilities,
Or a pure VCL component like THtmlViewer.
I like very much THtmlViewer since it won't depend on the IE installation, is pretty fast and has good printing abilities. You can even export to pdf if needed, using e.g. Open Source SynPdf unit.
I'm having the following problems using Javascript and img tags in the standard HTML component in AIR:
1- Javascript in the xml literal causes problems (even though it shows using them here: http://livedocs.adobe.com/flex/3/html/ProgrammingHTMLAndJavaScript_07.html#1032824
2- Using html.loadString(...<img src="/tmp/me.jpg" />...) does not show the image.
3- After wrapping the Javascript in CDATA tags it is still not accessible and returns an 'invalid function' error when trying to reach it.
The second 2 issues seem to go away if I save the html to a file and load it with html.load(file) instead of trying to read it as a string. Any suggestions to solve these issues?
I ended up saving the file to a temporary file and using html.load(tempfile).