Modify ↓
#8013 closed enhancement (fixed)
Specify default values for parameters
| Reported by: | Owned by: | Álvaro Iradier | |
|---|---|---|---|
| Priority: | normal | Component: | ParametrizedTemplatesPlugin |
| Severity: | normal | Keywords: | |
| Cc: | Trac Release: | 0.11 |
Description
Is there possible to specify some default values for a field?
Attachments (0)
Change History (5)
comment:1 Changed 15 years ago by
| Status: | new → assigned |
|---|
comment:2 Changed 15 years ago by
I've made the changes this morning. This is for 0.11
Index: parametrizedtemplates/parametrizedtemplates.py
===================================================================
--- parametrizedtemplates/parametrizedtemplates.py (revision 9404)
+++ parametrizedtemplates/parametrizedtemplates.py (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 match.group(1) not in existing_fields:
existing_fields.append(match.group(1))
- fields.append((match.group(1), match.group(2), match.group(3)))
+ fields.append((match.group(1), match.group(2), match.group(3), match.group(4)))
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]}"/>
</py:choose>
<em>${field[0]}</em>
</div>
Maybe you could include the change in your next release. Cheers
comment:3 Changed 15 years ago by
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.
Greets.
comment:4 Changed 15 years ago by
| Resolution: | → fixed |
|---|---|
| Status: | assigned → closed |
comment:5 Changed 15 years ago by
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.
Note: See
TracTickets for help on using
tickets.



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