İs that possible to give an attribute like that?
src="${urlPath}/img/icon-{{flight.OperatingAirline._CompanyShortName}}.png"
doesn't works.
Use :v-bind (or shortcut ":") instead of "{{ }}" : v-bind
So :src="Any javascript here !"
:src="urlPath + '/img/icon-' + flight.OperatingAirline._CompanyShortName + '.png'"
urlPath and flight.OperatingAirline._CompanyShortName must be a javascript variable.
After edit #SLYcee's answer for JSTL combined solution:
:src="'${urlPath}/img/icon-' + flight.OperatingAirline._CompanyShortName + '.png'"
Related
I need to generate the dynamic file path in the setup thread group like below.
def result_file = new File(org.apache.jmeter.services.FileServer.getFileServer().getBaseDir() + File.separator + 'transactions_passed_' + new Date().format('MM_dd_yyyy_HH_mm_ss') + '.csv');
props.put("result_file", result_file);
Now I want to pass that file path as a filename value of Flexible File Writer plugin of jmeter so that variables are stored inside it.
Not able to make it work. Kindly help. Thanks
I have tried below options:
Filename: ${__groovy(props.get("result_file").text)}
tried to use preprocessor and set the value:
vars.put("result_file", '${__FileToString(props.get("result_file"),,)}');
Also tried to use below groovy script in the FileName field of Flexible File Writer, however it throws an exception of FileNotFound exception:
${__groovy(new File(org.apache.jmeter.services.FileServer.getFileServer().getBaseDir() + System.getProperty('file.separator') + 'transactions_passed_' + new Date().format('MM_dd_yyyy_HH_mm_ss') + '.csv').text)}
I want to use DYNAMIC FILE PATH (which I am setting as property in setup thread group) in the FILENAME field of FLEXIBLE FILE WRITER
The approach with __groovy() function should work however you need to remove this .text bit from there
${__groovy(new File(org.apache.jmeter.services.FileServer.getFileServer().getBaseDir() + System.getProperty('file.separator') + 'transactions_passed_' + new Date().format('MM_dd_yyyy_HH_mm_ss') + '.csv'))}
because .text returns you the file contents and as the file doesn't exist - you're getting this FileNotFound error. More information on Groovy scripting in JMeter - Apache Groovy: What Is Groovy Used For?
I'm using ml-gradle to run a block of XQuery to update the MarkLogic database. The problem I am running into is I need to wrap all of the code in quotes, but since the code itself has quotes in it I am running into some errors when I try to declare variables i.e. let $config. Does anyone know a way around this? I was thinking I could concatenate all of the code into one big string so it ignores the first and last quotation.
task addCron(type: com.marklogic.gradle.task.ServerEvalTask) {
xquery = "xquery version \"1.0-ml\";\n" +
"import module namespace admin = \"http://marklogic.com/xdmp/admin\" at \"/MarkLogic/admin.xqy\";\n" +
"declare namespace group = \"http://marklogic.com/xdmp/group\";\n" +
" let $config := admin:get-configuration()\n" +
It bombs out when it is trying to declare $config as a variable. With the error:
> Could not get unknown property 'config' for task ':
Here is an example that works
task setSchemasPermissions(type: com.marklogic.gradle.task.ServerEvalTask) {
doFirst {
println "Changing permissions in " + mlAppConfig.schemasDatabaseName + " for:"
}
xquery = "xdmp:invoke('/admin/fix-permissions.xqy', (), map:entry('database', xdmp:database('" + mlAppConfig.schemasDatabaseName + "')))"
}
Here is some documentation for ServerEvalTask: https://github.com/marklogic-community/ml-gradle/wiki/Writing-your-own-task
I suspect you are hitting some string template mechanism in Groovy/Gradle. Try escaping the $ sign as well.
Note that you can use both single and double quotes in XQuery code.
HTH!
I want to assure that a variable representing a folder set by the user has an ending slash, so I can avoid bugs related to missing slash or double slash.
Mainly I am considering a repair task like:
- when: my_path[-1] != '/'
set_fact:
my_path: "{{ mypath }}/"
If this condition can be written in pure jinja2 even better as I could avoid creating an extra set_fact and put that trick inside a "vars" block.
Any better way to implement that? Apparently there is no in-build jinja2 filter to format paths.
You can write your own filter.
In ansible.cfg you can specify your filter directory:
[defaults]
filter_plugins=<path/to/your/library/of/filters>
And now you put in <path/to/your/library/of/filters>/path_filter.py:
from ansible.module_utils import basic
def canonical_path(path):
''' Verify that path ends with / and add / if not '''
if path[-1] != '/':
return path + '/'
return path
class FilterModule(object):
''' Ansible Filter to provide canonical_path '''
def filters(self):
return {'canonical_path': canonical_path}
That allows you to write in your playbooks
- name: Show canonical_path
debug:
msg: "Path is : {{ mypath | canonical_path }}"
I am using ansible to template a jinja2 file.
IP:{{ ansible_eth0.ipv4.address }}
IP:{{ ansible_docker0.ipv4.address }}
IP:{{ ansible_{{ ka_interface }}.ipv4.address }}
there is a var named ka_interface for network adapter.
but you will get error in 3rd var
(IP:{{ ansible_{{ ka_interface }}.ipv4.address }} )
It seems that var in jinja2 template can be nested.
It's not possible to construct a dynamic variable with Jinja2 syntax.
However, you can access any play-bound variables via the builit-in vars hash object:
{{ vars['ansible_' + ka_interface]['ipv4']['address] }}
Edit: Fixed hash syntax
follow Chris Lam 's advice,
It works
- name: test
shell: echo {{ vars['ansible_' + ka_interface]['ipv4']['address'] }}
tags: test
s="s=#;print(s.sub('#', s))";print(s.sub('#', "\"#{s}\""))
This code is supposed to print out an exact copy of itself but instead I am getting the following:
s="s=#;print(s.sub('#', s))";print(s.sub('#', s))%
It's almost there but the problem I'm having is getting the s variable in the s.sub parameter matching in the output string.
See this for more information on quine's: http://en.wikipedia.org/wiki/Quine_%28computing%29
Thanks for any help
s="s=#;print(s.sub('#', 34.chr + s + 34.chr))";print(s.sub('#', 34.chr + s + 34.chr))