Created the following JS live template:
console.log('$var$ -> ', $var$);
That can generate this:
console.log('response ->', response);
I would love to have auto completion within the string. OR have me edit the second $var$ and make the first one be the same.
Any way to accomplish that?
Playing with "edit variables" completion() and smartCompletion() did not seem to auto complete the local variables.
OK, choosing the JsArrayVariable() expression in the "edit variables" modal seem to be working as mentioned in the docs.
Couldn't find it at first as the docs's description of JsArrayVariable is not very clear:
JsArrayVariable: Returns JavaScript array name.
IMHO, a better description would be "Auto-select from a list of scope variables".
Related
I have a web-page that has an embedded Leaflet map. I've managed to create a drop-down for the user to select different maptile types from Maptiler.com. This worked fine with the maptile address being passed as context from the view which was then specified in my template as follows:-
L.tileLayer('{{ context.maptileaddress }}', {attribution: '© MapTiler © OpenStreetMap contributors',}).addTo(map);
I then decided that I might like to use other maptile providers such as Stamen and that would require me to pass the whole tilelayer argument as follows:-
L.tileLayer('{{ context.maptilefullkey }}).addTo(map);
where a valid 'maptilefullkey' is:-
'https://stamen-tiles-{s}.a.ssl.fastly.net/toner/{z}/{x}/{y}.{ext}', {
attribution: 'Map tiles by Stamen Design, CC BY 3.0 — Map data © OpenStreetMap',
subdomains: 'abcd',
minZoom: 1,
maxZoom: 18,
ext: 'png'
}
When I embed this text literally into the tileLayer method, the maptile displays just fine - see my print.
The maptile works fine when it is hardcoded into the the tileLayer() method
You can also see that I have successfully passed
{{ context.maptilefullkey }} to the template and it has printed at the bottom of the webpage successfully. It apparently matches the valid key exactly.
But when I pass it as a variable L.tileLayer({{ context.maptilefullkey }}).addTo(map);, the maptile completely disappears.
Why has this happened and how do I fix it?
Is the fact that the string ends in curly bracket and then precedes the double curly bracket that closes off the context creating a problem?
Or is it the attribution that is causing an issue?
The help from this community is much appreciated!
Phil #anoobinneed
I have managed to work this out in the end. It's all part of me being fairly new to this.
I needed to add the tag "safe" to where the fullkey is being picked up from:-
L.tileLayer({{ context.maptilefullkey | safe }}).addTo(map);
It worked previous when just the tileaddress was being passed but clearly the fullkey had an "unsafe" character or characters and I needed to instruct the template to pass the string exactly as it is.
This is explained quite well in the documentation:-
https://docs.djangoproject.com/en/3.0/howto/custom-template-tags/
I hope this may help someone in the future.
Phil
I'm using this x-editable plugin (https://vitalets.github.io/x-editable/demo-bs3.html) and specifically the "Custom input, several fields" located towards the bottom of the demo.
First, everything is working just fine on the implementation but I'm struggling with how to save the submitted data (see screen shot below further down). I don't know how to reference value[address1] in my sql statement without Lucee thinking its a structure (I hope that makes sense in what I'm trying to say here). When I try to reference the variable reports via writeDump(form.value[address1]), Lucee provides me the following error:
key [value] doesn't exist
How do I reference form fields in the image? Should I change how the data is being submitted perhaps using jQuery's serialize() method?
It was much easier than I thought. I didn't even know you could do this!
local.address1 = form['value[address1]'];
Thanks to the comment made by #Matt-Busche in the SO question, ColdFusion Variable Name with brackets.
How do I use a type-safe url with setMessage?
I want to change
...
setMessage [shamlet|<span .warning>Warning! See Help.|]
...
to a message that contains a link.
From what I could gather thus far, it ought to work somehow like this
...
renderer <- getUrlRender
let html = [hamlet|<span .warning>Warning! See #
<a href=#{HelpR}> Help!|]
setMessage $ toHtml $ html renderer
...
but that code just gives me confusing error messages all over the file.
I did read the printed Yesod Book Chapter on Shakespearian Templates, but I found that it is not very explicit on the involved types. For instance what type does [hamlet|...|]| produce? Without URL-Interpolation, ghci reports t -> Markup but with URL-Interpolation inside, I just get errors.
I am further confused by all the type synonyms involved, e.g. [shamlet|...|] delivers something of type Html, while setMessage expects a Html (). I do not know how to look these up easily: Hoogle often finds nothing on the topic, while Google always finds possibly outdated versions (with examples that no longer work) - sure I get to the newest version eventually, but is there a place where I get an easy overview over these? (Can ghci list all synonyms for a type?)
Note that I actually want to produce the message in a purely functional code fragment, which is later on used by a handler. So that is why I would like to separate the URL rendering from where the hamlet is specified. Thanks for any pointer in the right direction!
I think you want to use getUrlRenderParams. Strangely enough, a related discussion came up on IRC today. Hamlet templates take a URL rendering function as their first argument, and that function must take two parameters: a type-safe URL, and a list of query string parameters. getUrlRender returns a function that doesn't take the query string parameters, which is why you need getUrlRenderParams instead.
I have seen different templates that doesn't let us see their position names. When I add ?tp=1 to website link, they show [object arguments] instead.
I think these frameworks use T3 template engine (?). [what ever T3 is, it doesn't matter for me]
I'm not looking for these answers:
Please tell me what the template name is? Visit its official demo url (for example http://joomla17-templates.joomlart.com/ja_elastica/?tp=1 or another demo) This is not a real answer!
Update your template! This is not also a working answer. It doesn't matter to template updgrades. Because I can see somebody in the link that has updated his template, but that hasn't worked.
UPDATE
Unfortunately also the official demo of the template has the problem: http://demo.bowthemes.com/bt-arise/?tp=1
Your second link had the answer -
I enabled that plugin, 'System - Language Code' and lo and behold, the template module positions were back.
I'd start with that because the T3 framework definitely displays module positions.
I am using JRules to author business rules. I want to add comments to the rules as shown in the very simple example below. I realise there is a documentation section for the rule but that is not what I require
// comments needed here
definitions
set 'an existing customer' to a customer
where the category of 'an existing customer' is "gold"
if
the city of 'an existing customer' is "London"
then
give a 5% discount to 'an existing customer'
else
// and more comments needed here
give a 10% discount to 'an existing customer'
Clearly, using the usual c++ and c# double forwardslash // will not work in the example above, so my question is how are comments added to rules in BAL.
Unfortunately you cannot add comments in rules. The rules are supposed to be self explanatory if the verbalization is good.
But you can use the documentation feature,if you want to document the business justification for each of the rules.
There is a simple workaround:
You can create 2 static virtual methods in your BOM: one commenting the conditions and one for the actions.
In the case of conditions:
Create a static method that takes a parameter String and return a boolean
Verbalize it like this "// {0}" (without quotes)
In the B2X, make it return true
Then, you can comment a condition with //"your_condition" and ...
In the previous example:
if
the city of 'an existing customer' is "London" and
// "blablabla" and
the age of 'an existing customer' is greater than 18
then ...
Since the method returns true, it won't affect the test. It has to be surrounded by "and", not "or".
In the case of actions:
Create a static method that takes a parameter String and return void
Verbalize it like this "// {0}" (without quotes)
In the B2X, add "return;"
Then, you can comment an action with //"your_action" ;
In the previous example:
else
// "and more comments needed here" ;
give a 10% discount to 'an existing customer' ;
You can do it but it means a hell lot of customization. So forget it
And it would be feasible only via browser interface, not Eclipse.
Just because you will be cheating.
How to do it:
Ready?... Steady?...
You need to recreate your own RTS (teamserver) web interface! if it sounds like too much effort then stop reading :)
Using the API, you can retrieve the rules from RTS (database) the there is (as mention in Tito's answer) a documentation attached to any rule.
So you can handle the display of your rule and add the comment accordingly.
Of course you need to find a way to position the comment correctly in the rule Line number could do the trick.
This is for the display...
Ten when you save the rule (by clicking a lovely button that you will have coded to do the actual saving) you need to remove the comments (and know where they are for the next time you want to display the rule) and save both the rule body and the documentation attached.
Sounds crazy? One client done it and I was working on this :) but we didn't modify the rule body. Almost everything but the rule body.
This will take you months, inpependently to the number of people working on it, I'm afraid.
To sum up: Can you do it, yes!
Does the implementation worth the effort? NO WAY!!!
Will this feature be available in the next version? NO! As Tito mentioned a rule should be self-explainatory.
Sorry :(