Topic on Talk:VisualEditor/Gadgets/Add a tool

Jump to navigation Jump to search

How to wrap selection in a simple template?

2
Varlin (talkcontribs)

Hi, following the examples given, I have been able to insert an all-defined template at cursor position, but unable to do something as simple as to wrap selection in a (mono-argument) template. I.e :

  1. I select "some text"
  2. I trigger the template
  3. I get "{{MyTemplate|some text}}"

I guess it is really simple but I spend hours trying to figure out how to do that... Any help would be highly appreciated !

EDIT : I precise I know how to do it using getText(), but it returns the plain text selection and so it removes the links and wikitext formatting.

Whatamidoing (WMF) (talkcontribs)

I don't know how to solve your problem, sorry.

Is it always the same template? I think this can be done with quotation marks, in the VisualEditor/Special characters tool, and (if your wiki only needs one template to work like this), I wonder if it might be faster and easier to pretend that {{MyTemplate| and }} were just strange quotation marks.

Reply to "How to wrap selection in a simple template?"