Change colour based on tags in Tumblr - tumblr

I'm trying to create a kind of IF statement using Tumblr tags.
Tumblr uses these shortcodes to output each post's tags:
{block:Tags}{Tag}{/block:Tags}
...which would output this:
"tag1tag2tag3tag4etc"
I would like to create something like...
If {block:tags}{tag}{block:tags} includes "red", return the hex for red. If it includes "blue", return the hex for blue, and if it returns "red", return red.
I'm guessing this will require javascript, which I've never used. This should be fairly simple though, and any help would be very much appreciated.

Related

outline for a custom document format

The same way HTML and JSON (but not YAML?) already have their navigable Outline, I would like to add the same ability for my custom format, to help me navigate thru lengthy text.
Where I can find documentation for doing so?
I have found "how to add a grammar for highlighting" which is partially useful, (https://code.visualstudio.com/api/language-extensions/syntax-highlight-guide), but not sure following this guide will provide me an Outline, again, YAML for ex. is highlighted, but doesn't appear in Outline.
Admittedly, I haven't read the entirety of the above link, but the word "Outline" doesn't appear, and I have trouble to filter search engine results.
Example below:
{
"doc1": {
"key": 12,
"a": [
1,
2,
3
]
}
}

How to filter tag values in template variable of Grafana?

all.
I'm new to Grafana and I want to get only tag values what I want.
For example,
As you can see,"23" is a value of tags, I just want to get template variable by "23".
But now I get so many template variables so that every time I have to seek it for long time.
I'd like to get some tags like "23" rather than seek it from all tags.
Thank you very much for your support.
Unfortunately you cannot use "IN" when filtering TAGs youll need to do something like this (i.e only show 23 and 24)
Your query should be
SHOW TAG VALUES WITH KEY "measurementPoint" where ("measurementPoint" = '23') or ("measurementPoint" = '24')
Ofcourse if you know its only going to be 23 or something else you could just use static variables or have i misunderstood your question ?

IBM Watson Assistant, how can I remove multiple items from an array?

I have a list unmentioned_colors = ["red", "green", "blue", "yellow"]
If I mention multiple colors, I want to update my unmentioned_colors array, removing the ones that I mentioned. So if I write "red green" I want to remove them from unmentioned_colors where it will become ["blue", "yellow"]
I tried
unmentioned_colors = "<? $unmentioned_colors.removeValue(#colors.values) ?>"
But it is not working.
How can I remove multiple #colors from my array?
Watson Assistant supports two methods to remove an item from a JSONArray, remove (using the index) and removeValue (using the value). Each method removes exactly one element. So you would need to loop / iterate over the elements to delete and then invoke the method. Could you process this in the app?
Another approach is to look into SpEL (the expression language) and work with collection selection / projection.
To remove all #colors items from $unmentioned_colors one should set a context variable $_bool_listchanged as shown here:
_bool_listchanged = "<? $unmentioned_colors.removeAll(#colors.values) ?>" .
This solution does not require a loop and works because underneath the hood Watson Assistant uses Java to manipulate items in the contact. So on this array we have the method removeAll which we can call from Java.

Trying to use EJS to dynamically render an edit form

The problem seems to be with EJS. I might be trying to do something EJS wasn't designed for.
I'm working on a web app that uses forms with a variable number of fields. If a Mongo document I'm editing has only one field, I don't want to display input boxes for any additional fields.
I'm able to dynamically control how many fields are displayed when documents are edited but I'm not able to dynamically display the current value of the fields.
If I use the value tag like this: value=<%= document.field1 %>, it works fine. This, however, would have to be manually repeated for each field, including fields that won't be present.
What I want to do is something like this: value=<%= 'document.field' + (i+1) %>. This would ideally produce the same rendered HTML the code above does. However, what I see is 'document.field1' rather than the data I want to retrieve from the database.
EJS is just a thin wrapper around JavaScript code. Anything you can write in JavaScript you can write in EJS, it'll be included in the compiled template without modification.
So to reference a field with a dynamic name you'd use [] just like you would in any other JavaScript code. Based on the code you provided it would be something like this:
value="<%= document['field' + (i + 1)] %>"

Using jQuery how can you select all DOM elements that have a pixel value set in the source HTML?

I'm writing some tests and one of the assertions has to ensure an HTML document only uses px units of measurement where specified. I'm using jQuery but I can't work out the way to select those elements. These elements will be the ones with things like margin and padding specifically set and not just the inherited values or pixel values converted from em etc.
Cheers
I'm not sure exactly what you're dealing with, but if these elements have the pixel values set in the "style" attribute, you could use something like
$([style*='px']);
For all of the elements with a style attribute which contains the letters "px". Otherwise, if they are explicitly set in the "width", "padding", and "margin" attributes, it would be something like
$([padding*='px']);
You can read more about the "contains" selector in the jQuery API here:
http://api.jquery.com/attribute-contains-selector/
If this doesn't answer your question, you'll have to be a little more clear about the structure of your document, and perhaps provide some example code.