Is there any way to escape a percent symbol?
I'm trying to document some of the commands I use in our KB.
One of them involves "$(date +%Y%m%d)" which inserts todays date as a string.
The issue is that Matrix is interpreting %Y% as a keyword so all I get on the frontend is "$(date +m%d)" which is not what I want.
I tried using "& #37;" (without the space and quotes) which is supposed to be a percent symbol but when I submit the page the entity is converted back to an actual percent sign.
Is there some other way to escape a percent sign?
I should probably mention our KB is still on 3.16.6 SSV.
Escape a percent symbol?
Hi David
You can turn off keywords in the container properties when editing, little orange icon at the top left.
Are you using jQuery for this?
If I were you, I would just put all your javascript into an external .js file. That way, your code is nice and clean in one place, AND, Matrix won't touch the file, so you can put whatever you want in it.
No jQuery.
Turning off Keywords for the whole div is a bit of a sledge hammer, but will do for this particular problem.
Is there really no syntax for escaping percent symbols?
Something like %percent% as a global keyword that printed a percent would do…
Yep it is, especially if you want to use them for other parts of the page. I often battle with this kind of thing, but the alternatives need some out of the square thinking and a little bit of time:)
Try "$(date +%%Y%Y%%m%m%d)" it works in 3.18 but I don't have 3.16 handy to test.
Yeh that works to, but I'm pretty sure that's dependent on the way keywords are currently found (preg_split?) and could have interesting results if they are ever found a different way.
What's actually happening there is the regex is passing over "%%Y%" and matching the bit in bold as a keyword (because there is actually one or more alphanumeric char in between the percents).
I could also write it as "%%escape%Y%%escape%m%%escape%d" (the bold bits become null keywords) which at least explains why there is a stupid series of keywords there when a user is viewing the WYSIWYG, but it is a dodgy hack dependent on the current implementation which I always figure is a bad thing.
So, are you telling me you are NOT using javascript?
If you are, I don't get why you just can't put it in an external file like I said before, and problem solved.
David,
Yeah, a completely dodgy hack, would love for someone else to make our day with a better way to do this.
Nic,
Unless I am mistaken, David just want's to have this in content as content. If that is the case, what JS are you suggesting?
I'm wrapping small bits of bash code in with lots of documentation explaining them. It would be a huge workaround to place the bits of code in a javascript file.
The solution I'm actually using is to turn off the keywords as suggested and just insert a raw html div above it with a html comment in it stating that the keywords are turned off (to save any other editors confusion later on).
The point is not that there is no solution, simply that all the solutions are work arounds for what would normally be solved with an escape sequence of some sort.
[quote]David,
Yeah, a completely dodgy hack, would love for someone else to make our day with a better way to do this.
Nic,
Unless I am mistaken, David just want's to have this in content as content. If that is the case, what JS are you suggesting?[/quote]
Sorry, I guess I was misunderstanding the situation here! My bad.
Hey Nic,
I do have lots of q's about JS and your Jquery stuff around this. I have been using asset listings to generate keyword lists for nesting into other asset listings and I am getting stuck in a couple of spots.
I have created a setup that dynamically lists all the forms in a site and builds a query string that gets sent to a dynamic listing that creates a csv of the submissions of the form. This is to replace the need to set up a asset list for each form and is a one click way to export all the sub's for a non backend person.
Just need to document my setup and i will post the questions.
[quote]Hey Nic,
I do have lots of q's about JS and your Jquery stuff around this. I have been using asset listings to generate keyword lists for nesting into other asset listings and I am getting stuck in a couple of spots.
I have created a setup that dynamically lists all the forms in a site and builds a query string that gets sent to a dynamic listing that creates a csv of the submissions of the form. This is to replace the need to set up a asset list for each form and is a one click way to export all the sub's for a non backend person.
Just need to document my setup and i will post the questions.[/quote]
Sure, send me a PM or post any questions and I would be happy to help.