how do I interpolate string in ruby snippets?

Asked by Russell

How do I interpolate in ruby snippets given that '{' needs to be escaped?
I've tried the following variations but they do not work.

snippet in "interpolate ruby"
 $#{1:ruby_code}
endsnippet

snippet in "interpolate ruby"
 $#\{1:ruby_code}
endsnippet

Question information

Language:
English Edit question
Status:
Solved
For:
UltiSnips Edit question
Assignee:
No assignee Edit question
Solved by:
Russell
Solved:
Last query:
Last reply:
Revision history for this message
SirVer (sirver) said :
#1

I do not speak ruby, so you must define more clearly: what kind of output do you want to have in your snippet? the first version gives verbatim $#{1:ruby_code} which is exactly what I've would expect.

Revision history for this message
Russell (rbakerjax-d) said :
#2

First of all I should have said thank you for the great plugin. Thank you.

When running the above snippets I would like the following to be printed:

#{ arbitary_ruby_code}

Also, I would like the cursor to be at position 1 ( inside the braces ).

I can get everything working except the cursor position.

Thank you.

Revision history for this message
SirVer (sirver) said :
#3

How about

snippet in "Interpolate ruby"
#{${1}arbitrary code}
endsnippet

or

snippet in "Interpolate ruby"
#{${1:arbitrary code}}
endsnippet

Revision history for this message
Russell (rbakerjax-d) said :
#4

Thank you. Problem solved.