Tags:
create new tag
view all tags

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

TWiki version: TWikiRelease04x01x02
TWiki plugins:  
Server OS: Mac OS X
Web server:  
Perl version:  
Client OS:  
Web Browser:  
Categories: Missing functionality

-- RichMorin - 19 May 2008

Answer

ALERT! 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

Change status to:
Edit | Attach | Watch | Print version | History: r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r4 - 2008-06-08 - RichMorin
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.