Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#8013 closed enhancement (fixed)

Specify default values for parameters

Reported by: tudor@… Owned by: airadier
Priority: normal Component: ParametrizedTemplatesPlugin
Severity: normal Keywords:
Cc: Trac Release: 0.11


Is there possible to specify some default values for a field?

Attachments (0)

Change History (5)

comment:1 Changed 6 years ago by airadier

  • Status changed from new to assigned

Not now, but sounds like an interesting feature. Patches are accepted, or I'll take a look when I get some free time.

comment:2 Changed 6 years ago by tudor@…

I've made the changes this morning. This is for 0.11

Index: parametrizedtemplates/
--- parametrizedtemplates/      (revision 9404)
+++ parametrizedtemplates/      (working copy)
@@ -121,10 +121,10 @@
     def _find_fields(self, text):
         fields = []
         existing_fields = []
-        for match in re.finditer(r'{{\s*(.*?)\s*,\s*(.*?)\s*(?:,\s*(.*?)\s*)?}}', text):
+        for match in re.finditer(r'{{\s*(.*?)\s*,\s*(.*?)\s*,\s*(.*?)\s*(?:,\s*(.*?)\s*)?}}', text):
             if not in existing_fields:
-                fields.append((,,
+                fields.append((,,,
         return fields
Index: parametrizedtemplates/templates/newpage.html
--- parametrizedtemplates/templates/newpage.html        (revision 9404)
+++ parametrizedtemplates/templates/newpage.html        (working copy)
@@ -50,8 +50,8 @@
         <div class="field">
             <label for="field_${field[0]}">${field[1]}:</label><br/>
             <py:choose test="">
-                <textarea py:when="field[2] == 'textarea'" name="field_${field[0]}" id="field_${field[0]}" class="template_textarea" value=""/>
-                <input py:otherwise="" type="text" name="field_${field[0]}" id="field_${field[0]}" class="template_text" value=""/>
+                <textarea py:when="field[2] == 'textarea'" name="field_${field[0]}" id="field_${field[0]}" class="template_textarea">${field[3]}</textarea>
+                <input py:otherwise="" type="text" name="field_${field[0]}" id="field_${field[0]}" class="template_text" value="${field[3]}"/>

Maybe you could include the change in your next release. Cheers

comment:3 Changed 6 years ago by airadier

Thanks very much! I would only change the regular expression to use named groups, it's quite complicated. I'm taking it for next release.


comment:4 Changed 6 years ago by airadier

  • Resolution set to fixed
  • Status changed from assigned to closed

(In [9437]) Added support for default value in the parameters. Closes #8013

comment:5 Changed 6 years ago by airadier

Feature included in version 0.3. Changes from your patch are:

  • Using named groups, the regular expression was getting quite complicated.
  • Keep the "field_type" parameter optional. If you specify a default value, field_type must be specified too. If not, both can be omitted.

Add Comment

Modify Ticket

as closed The owner will remain airadier.
The resolution will be deleted. Next status will be 'reopened'.

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.