Reputation: 465
I noticed that IntelliJ has syntax for "set", "if" and "foreach" statements to build file templates.
http://www.jetbrains.com/idea/webhelp/file-and-code-templates.html. However, it doesn't seem like this is possible with live templates. Am I doing something wrong, or do they just not have this support?
Basically I'm looking for the same functionality as TextMate's snippets. It would be nice to create a script that would generate or transform text exactly how I want using tools like bash, perl, python or php (but I'd settle for #if and #foreach if that's possible too). And it looks like the IntelliJ TextMate plugin doesn't support this either, so is there any other plugin that would accomplish this?
Upvotes: 1
Views: 933
Reputation: 1
Yes, It is possible. Use groovyScript in variable. Example:
groovyScript("def TABLE_NAME=\"${_1}\"; def resultStr=''; for(i = 1; i <= 99; i++) { resultStr+=\"\"\" \n CREATE TABLE ${TABLE_NAME}_${i} PARTITION OF ${TABLE_NAME} FOR VALUES IN (${i}); \"\"\"; }; return resultStr;", clipboard())
enter image description here
Upvotes: 0
Reputation: 465
I figured out the answer to this. It looks like you can use Groovy scripts in live templates with the groovyScript("groovy code")
predefined function
Upvotes: 2