I have the following code that's causing a Slim::Parser::SyntaxError:
p
code.inline /charge
I expect this to output <code class="inline">/charge</code> but it's just causing Slim to get upset.
Why?
Solved it using the escape character ', like so:
p
code.inline
'/charge
Hacky, but whatever .. it works.
Related
I'm calling a webService using AFNetWorking and want to pass a parameter of this shape,
112212234234324#abcdefghi_def.ab\/AB
and to achieve that i'm using following code,
#{#"someKey":[NSString stringWithFormat:#"%##%#\/AB", someTextField.text, [aDictionary objectForKey:#"someOtherKey"]]};
But stringWithFormat is ignoring backslash and value for someKey is,
112212234234324#abcdefghi_def.ab/AB
I've also tried this,
#{#"someKey":[NSString stringWithFormat:#"%##%#\\/AB", someTextField.text, [aDictionary objectForKey:#"someOtherKey"]]};
but it won't treat double slash as single slash and someKey value is,
112212234234324#abcdefghi_def.ab\\/AB
NSLog is converting fine.
NSLog(#"\\"); gives \
NSLog(#"\\\\"); gives \\
NSLog(#"\\/"); gives \/
Please help.
Try this one:
#{#"someKey":[NSString stringWithFormat:#"%##%#%#/AB", someTextField.text, [aDictionary objectForKey:#"someOtherKey"],#"\\"]};
Just solved it by skipping \. After discussing with backend team, i came to know that backslash will be ignored anyways by parser so it isn't needed.
Updated code looks like,
#{#"someKey":[NSString stringWithFormat:#"%##%#/AB", someTextField.text, [aDictionary objectForKey:#"someOtherKey"]]};
I wanna get specific information from a log line by line,
the following is one line of log(the format is the same for the rest):
...
2010/11/22-00:00:01 - [TEST1][01.01. case1][1]
...
problem is I got nothing by using following code,
for a in str:gmatch("(%d+/%d+/%d+-%d+:%d+:%d+) - [TEST1][(%d%d.%d%d. (%C+))]") do
print(a)
end
any suggestion will be appreciated!
-, [ and ] are all magic characters in lua patterns. You need to escape them %-, %[, %].
Edit: Useful addition from #hjpotter92. . is also "magic" and should be escaped %. to match only a literal ..
I have a problem with sorting an array which have strings with special Polish characters. My code looks like this:
["Łotwa", "Luksemburg", "Anglia"].sort_by{|x| ActiveSupport::Inflector.transliterate(x)}
and this code gives me the following result:
["Anglia", "Łotwa", "Luksemburg"]
but it should look like this:
["Anglia", "Luksemburg", "Łotwa"]
I tried to use these gems:
https://github.com/grosser/sort_alphabetical
https://github.com/jarib/ffi-icu
but they do not solve this problem. Problem is caused by the special Polish character "Ł".
You can use string_case_pl gem:
require 'string_cmp_pl'
%w(Anglia Litwa Zanzibar Łotwa).sort
# => ["Anglia", "Litwa", "Łotwa", "Zanzibar"]
I'm making a reusable package and in order to get the client side to work both with straight javascript and module loaders I have a code paths that requires me to document.write out script tags.
In my razor view I have something like this:
<script>
...
document.write([
'<script type="text/javascript" src="~/Oaf/SlimHeader/Media/Scripts/jquery-1.9.1.min.js"></script>',
'<script type="text/javascript" src="~/Oaf/SlimHeader/Media/Scripts/jquery-migrate-1.2.1.min.js"></script>',
].join('\n'))
...
</script>
Which Razor refuses to interpret in html mode:
Parser Error Message: Unterminated string literal. Strings that start
with a quotation mark (") must be terminated before the end of the
line. However, strings that start with # and a quotation mark (#")
can span multiple lines.
indicating the error is in the first script tag. This is javascript, I don't want Razor involved at all! (Ok, it would be nice if it parsed the ~ but honestly I can take care of that myself).
I've tried prefixing every line with #: and surrounding the whole thing in #" ... "# but neither seems to work.
This is not a razor issue, this code is invalid even in a simple HTML file, and will cause problems in the browser.
The solution is to:
var a = '<script><' +' /script>';
The bug has been closed as by design.
Thanks to Aron who got me to pare this down thereby prompting me to discover the answer.
Pared down the broken code looked like this (I hadn't included the if in the question):
#if (true) {
<script type="text/javascript">
var a = '<script></script>';
</script>
}
something in the interplay between the #if and the <script> tag in a sting just does not sit well. If I force text mode on each line inside the if by prefixing with #: then it works.
In the original question the solution it to prefix every line inside the Razor block with #:. Surrounding in a <text> block will not work. If you don't prefix every line with #: then you will get a parsing error very possibly for a line that was prefixed.
Seems like a bug with Razor. Will report it.
i have a snippet call like this:
[!mysnippet?&content=`[*content*]` !]
What happen is that, if i send some html like this:
[!mysnippet?&content=`<p color='red'>Yeah</p>` !]
it will return this:
<p colo
the [test only] snippet code (mysnippet) is:
<?php
return $content;
?>
Why is this happening?
My actual snippet is converting html to pdf, so i really need this.
Thank you all ;D
EDIT: I'm using Modx Evo 1.0.2
MODx Evolution has a limitation whereby you can't use "=" (equals signs) in Snippet parameter values. Best solution is to place the content in a chunk or TV and then call it. This is not an issue in MODx Revolution.