Question
I have a TWiki page that contains many variations on the following
(view in raw mode to see the code):
mysql> desc schema_info;
+---------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------+---------+------+-----+---------+-------+
| version | int(11) | YES | | NULL | |
+---------+---------+------+-----+---------+-------+
I would like to accomplish this using much shorter and simpler code, as:
DWIM{ name="schema_info" body="
+---------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------+---------+------+-----+---------+-------+
| version | int(11) | YES | | NULL | |
+---------+---------+------+-----+---------+-------+
"}
I don't much care about the actual syntax of the invocation,
save that it should be considerably shorter and simpler
than the TWISTY code it expands to.
FYI,
VickiBrown and I tried a number of approaches,
using INCLUDEs and
MacroPlugin, without success.
So, we're open to suggestions...
Follow-up
Thanks, Peter!
The first approach seems to require a new "Set" line for each table I want to TWIST.
And, because it's all on one line, it's even harder to read than the TWISTY code.
So, no help there, unless I'm misunderstanding something.
However,
ParameterizedIncludes are just the thing!
I've defined a couple at
http://cfcl.com/twiki/bin/view/Projects/Arti/WebIncludes
and am using them a zillion times in
http://cfcl.com/twiki/bin/view/Projects/Arti/Patterns/DB_MySQL
Once again, TWiki has what I need!
Environment
--
RichMorin - 19 May 2008
Answer
If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.
Let's see if s preferences setting can come to rescue:
* Set TWISTY_SCHEMA_INFO = %TWISTY{mode="div" showlink="<tt>schema_info</tt>" hidelink="<tt>schema_info</tt>" showimgleft="%ICONURLPATH{toggleopen-small}%" hideimgleft="%ICONURLPATH{toggleclose-small}%" }%
This setting is done on the page level. It probably makes more sense on teh web level or site level. Now let's try to use this setting:
%TWISTY_SCHEMA_INFO%
<verbatim>
mysql> desc schema_info;
+---------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------+---------+------+-----+---------+-------+
| version | int(11) | YES | | NULL | |
+---------+---------+------+-----+---------+-------+
</verbatim>
%ENDTWISTY%
Which renders as:
mysql> desc schema_info;
+---------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------+---------+------+-----+---------+-------+
| version | int(11) | YES | | NULL | |
+---------+---------+------+-----+---------+-------+
Alternatively, you could use
ParameterizedIncludes.
--
PeterThoeny - 19 May 2008