Mediawiki - what is the difference between If and #if? - mediawiki

What is the difference between a
{{If| ... }}
and
{{#if| ... |}}
in MediaWiki?
Which one should I use?

{{if|...}} is a template, {{#if:...}} (mind the colon) is a parser function. The if template probably uses the if parser function internally, you can see that by going to Template:If on the wiki this is on. To learn more about the parser function, go to https://www.mediawiki.org/wiki/Help:Extension:ParserFunctions##if

Related

Thymeleaf Fragments: How to pass String to Fragment to be used as onchange method

I am having an issue with the relationship between my Thymeleaf content file and fragment file that it uses. From the content file, I am passing many parameters to the fragment that are successfully rendered. However, one parameter that isn't working is a string that I'm passing that is to be used as an onchange method. The error I'm getting is that Method call: theMethod() cannot be found... Here is a simplified snippet of the content file that I'll call content.html:
<div>
<span th:replace="inputs::myInput('idExample', 'theMethod()')"></span>
</div>
And then here is the simplified snippet of the fragment file that I'll call fragment.html:
<span th:fragment="myInput(id, onchange)">
<select th:id="${id}" th:onchange="${__${onchange}__}">
...
...
...
</select>
</span>
Now, theMethod() is defined in a .js file that I have tried including directly as a src in both the content.html and fragment.html files, and it still gives the same error that the method call can't be found. And even if I directly define a theMethod() function in content.html and/or fragment.html, it STILL gives the same error. So I'm thinking maybe the structure of what I have in the th:onchange could be incorrect but not sure. For example maybe the ${__${}__} structure is wrong because I'm not that familiar with the detailed Thymeleaf syntaxes out there.
${__${onchange}__} is trying to run ${theMethod()} as Thymeleaf code -- which is having the Thymeleaf interpreter try to run the java function theMethod().
That being said, if you change it to th:onchange="${onchange}", you probably ran into the error Only variable expressions returning numbers or booleans are allowed in this context, any other datatypes are not trusted in the context of this expression
Thymeleaf really doesn't want you try and build JavaScript expressions and output them in html attributes because of the security vulnerabilities that can happen because of this. They typical way to solve problems like these is to pass function arguments to th:data-* attributes and then have hardcoded JavaScript like this:
<select th:data-id="${id}" th:data-name="${name}" onchange="onChange(this.getAttribute('id'), this.getAttribute('name'))">
That may or may not be directly applicable here -- so there is no easy way to solve your problem without restructuring the way you are handling onChange events.

Understanding Blazor props syntax

I know C# but been mostly programming React lately, I'm now looking at Blazor and trying to understand its quirky syntax.
I'm seeing in different examples that when passing props (attributes) to components an # sign is being used in various locations:
examples I've seen:
before attribute value, inside quotes
<Component title="#SomeValue"/>
before attribute value, no quotes
<Component title=#SomeValue/>
before attribute name
<Component #title="SomeValue"/>
What are these? I noticed that having no # often works the same as with it. Official documentation doesn't go to depth re this
I'm seeing in different examples that when passing props (attributes) to components an # sign is being used in various locations
Yes, this has changed a few times over the preview releases. As a consequence, some blogs and samples will be out of date. So first thing to check: how old is this code or article?
The official docs don't talk about those changes but they are up to date with the latest version.
The main changes were in preview6 : "In this Blazor release we’ve standardized on a common syntax for directive attributes."
My simple summary: Blazor attributes (directives) start with #, normal HTML attributes do not.
The values of those attributes (binding or eventhandler) do not need a #
In a later preview it was determined that attibutes should be case-sensitive.

What does the "_" function in Vala do?

I've seen that some projects used _ function that takes string as an argument, like _("Hello World"). But I couldn't find any manuals or articles about what is it and how to use it.
I guess this has something to do with i18n and l10n (it was mentioned in some article I found on the internet), but can you explain to me how it works and how to use it?
That is the GNU gettext localization function. You can provide language specific alternate strings for the one specified in the function call.
There is the xgettext tool, which generates a .pot file (abbreviation for portable object template) from your application code, then translators can make .po localization files for it. Then, you can bundle these with your application, and deliver a more widely usable piece of software.
I18n. See gettext example here: https://ewgeny.wordpress.com/2012/05/10/supporting-multiple-languages-in-your-application-a-simple-gettext-step-by-step-example/
Also found some info about what exactly this function do, it seems to be the macro for Glib.dgettext() function in Vala, this is from valadoc.org:
dgettext
public unowned string dgettext (string? domain, string msgid)
This function is a wrapper of dgettext which does not translate the message if the default domain as set with textdomain has no translations for the current locale.
...
Applications should normally not use this function directly, but use the _ macro for translations.

extractValue function to extract from HTML?

So I was working with webload and was using a function called extractValue, but when I googled it to try and find proper use of it, I learned that it is actually a SQL function for extracting XML values (? is this correct?). Now seeing as that XML and HTML are both markup languages, I figured that maybe it would apply for both HTML and XML? But then I realized that extractValue for XML follows the form extractValue(xmldocument, startpoint, endpoint), while an example for the extractvalue i am using looks like
roughNKEY = extractValue("\"NKEY.DUMMY.MENSYS.1\"", "/", document.wlSource, 1)
which seems to have the form extractValue(startpoint, endpoint, htmldocument(i think it's reading from the html page?), 1)
I have no idea where this usage is from or even what language it's in, but it works for the purpose. Does anyone know where I can find more information on this? Is this just like a function exclusive to webload or something?
Thanks
Please review the documentation. You can find it in:
C:\Program Files (x86)\RadView\WebLOAD\help_files
There are three documents that contain information about extractValue:
javascript reference manual
scripting guide
IDE user guide
ExtractValue is also generated by the Correlation engine.
In order to extract a value from the page source, you need to insert:
wlHttp.SaveSource = true
Into the IDE node you want to search.

Force function documentation in Doxygen for documenting JavaScript API

I use Doxygen for documenting the JavaScript API of my C++ (Qt) project. The idea is to write one specific documentation for the JavaScript interfaces, and one for the C++ classes us usual.
One example (datasource.dox) looks like this:
\addtogroup JavaScriptAPI
#{
...
\class DataSource
\brief DataSource is the .... some doc goes here ....
\section formats Supported formats
....
\fn isOpen()
\brief returns true if the data source is currently open...
...
#}
The generated help looks nice w.r.t. the class description (or 'object'-description), but the function documentation (isOpen(), ...) is missing. Doxygen creates warning messages like:
Warning: documented function `bool isOpen' was not declared or defined.
The question, now: can I somehow force doxygen to use my \fn-d function descriptions? It would be nice, if doxygen created all those member indices for me...
Two approaches for using doxygen with Javascript are listed here http://www.doxygen.org/helpers.html
(look for JavaScript)