How do I escape the single quote in Rythm? - rythm

getAddress()
output: Test'Street'Address
There are multiple templates that need to be addressed. Please do let me know in case if there is an option configure at one place that fixes all templates.
Any ideas/suggestions will be appreciated.
Thank you for your time.

I suppose you are in either JavaScript or JSON region, in which case Rythm automatically escapesthe variable output using JavaScript escaping.
If you need the literal output, please use .raw() transformer. E.g. you change #myVar.getAddress() into #myVar.getAddress().raw()
For more information about escaping, please refer to http://rythmengine.org/doc/expression.md#escape

Related

Kentico Nested Macro Comparison

I want to compare a url to a specific path to see if they match. I have tried so many variations and just can't get it to work, the two items I need to use are
{%CurrentDocument.RelativeURL.Replace("~","")%}
and
{&/{0}/{1}/{2}|(tolower)&}
In the current test scenario, both of these return the same string, however, when I put them together
{%CurrentDocument.RelativeURL.Replace("~","")|(equals){&/{0}/{1}/{2}|(tolower)&}|(truevalue)yes#%}
I get a false result displaying, I'm pretty positive it's because I can't nest a path expression inside an expression but not sure if there is another way? Any help would be appreciated.
Thanks
According to the documentation you should be able to substitute path macro with {%Path.path%}. Then there is no need to nest different types of macros but use the Path the same way as CurrentDocument.

QTP fails to recognize Java-applet Jtree object when used with Regular Expression

I am using QTP for automating an application. QTP recognizes Java applet- JTree as a html tag. In the html tag we have a number which is dynamic.
Hence we used Regular Expression so that QTP recognizes the object even if the number changes. But QTP is failing to do so. We have tested the regular expression in the evaluator and it works highlights the correct number as expected.
The expression in Obj Repository matches with the one in the Expert view.
Reg expressions do not work with html tags/applets is it??
Is there any other way to deal with dynamic elements in html tags??
Thanks in advance.
Try using descriptive programming it may help you. If you could provide more details of the issue then i could send you code snippet.
You should try UFT that is the next generation of QTP.
If you have a QTP-Licence you can update to UFT and I guess it will work well.
On the other hand how long will QTP will be supported

grave in the Go Language

After looking around for a while I was able to understand how the json: tags are used in the Go language. However two tags I have come across I'm still lost on, and can't seem to find documentation on it.
Both pertain to a REST api service and the full code can be found here-> code.google.com
What is the root: tag used for
gorest.RestService `root:"/orders-service/" consumes:"application/json" produces:"application/json"`
as well how does the method: tag work?
userDetails gorest.EndPoint `method:"GET" path:"/users/{Id:int}" output:"User"`
I didn't know if anyone had any links to a site or document that might explain this more, from the examples I can learn enough to use it. However, I would really like to fully understand it.
Thanks for your time!
Tags are nothing but strings, they don't have any meaning per-se.
Libraries can use reflection to introspect struct fields and interpret their tags. See reflect.StructTag.
In your case, gorest parses the following tags on Services:
root
consumes
produces
and these on Endpoints:
realm
method
path
output
input
role
postdata
Their meaning is described in gorest's documentation.
These are gorest tags. See gorest wiki http://code.google.com/p/gorest/wiki/GettingStarted

wampserver configuration - how to enable constants?

In my main php file I use the method define() to set some constants. The idea is to use them to load some user settings and other configuration controls, but when the time to use them comes an error message is displayed like this:
Notice: Use of undefined constant CONSTANT_NAME - assumed 'CONSTANT_NAME' in (file path) on line X
For some problems there is a work around, declaring a variable is useful but does not solve all the problems.
Thanks in advance!
PS: I use a settings file too but the problem persists.
OK, the mistake was that CONSTANT_NAME was interpreted as a string because of the absence of single or double quotes. A small mistake born only for eagle eyes!
Correct way is: defined('CONSTANT_NAME');
They do not need any special settings. You just create one like:
define('TEST_NAME', 'biotox');
and you should be able to call it with:
echo TEST_NAME;
and the output should be biotox. I tested it on my WampServer without a problem.

What's the best way to escape vars in Zend_View automatically?

A week or two ago I just started using Zend Framework seriously and have had trouble escaping manually with Zend_View::escape().
Does anyone knows how to escape vars in templates (Zend_View templates) automatically without using $this->escape(), or any other tricky ways like output buffering and PREG replacing *.phtml files.
I'd like to know the best practice in this case.
You can extend Zend_View to create a custom view class which autoescapes things, or you can use a view helper to turn autoescaping on/off.
I have written a blogpost about it, with example code for both approaches:
How to automatically escape template variables in Zend_View
Over at the PiKe project we build a custom stream wrapper that automatically escapes all view variables, with a MINIMAL performance hit! You can still get the RAW value with:
<?=~ $variable ?>
Notice the "~" character. Checkout http://code.google.com/p/php-pike/wiki/Pike_View_Stream
I know you said that you want to avoid "tricky ways like output buffering and PREG replacing *.phtml files.", but I still think it's a very neat way to fix auto escaping in Zend Framework 1.
You said "automatically", so I believe that that means when you do echo $this->var; you want it escaped. Well, if that's the case, maybe you could do the escaping when the variable is set to the view. AFAIK it's done in the Zend_View_Abstract class' __set magic method* (around line 300). Changing the core ZF code is not recommended, so you could go by extending Z_V_A or Z_V and just override the __set method.
*I'm not 100% sure that Z_V_A::__set is the only place where the params are assigned to the view, but I think it should be. Can't think of any other place for that.
Edit: Personally, I'd avoid this and just stick with the good ol' $this->escape(). More typing but less magic going on in the background.
You have asked for best practice then what you are doing is already it.
Wait till when you want to display your data before modifying it only for output reasons.
I understand you find writting ->escape() everytime tedious but its still the way to go.
If you where to auto escape everything then you would run into problems one day when you want/need unescaped data.
ZendX_View_Autoescaping, this project provides you a ViewRenderer with autoescaping of all assigned view variables.
https://github.com/jensklose/ZendX_View_Autoescaping
Try it!
It supports:
escaping into deep data structures
escaping the array keys
possibility to switch the escaping context (html, json, nofilter)