This is a proposal to enable formatting of table cells.
My first attempt had a typo in the topic title:
TWikiFormatingInsideCells. The idea was
not to have reproductive processes inside cells
A cleaner and more general extension could be the introduction of the construct
<render> ... </render>
- The enclosed text shall be sent through the normal TWiki formatter and the fortmatted text shall replace the render construct
- The entire render construct (as well as its substitution) shall be regarded as a single token, i.e. the new-lines etc. inside it shall be ignored
- It shall be possible to nest render constructs, in which case these rules shall apply recursively
Table Example
| *foo* | *bar* | *foobar* |
|more foo | more bar | <render>
* more
* foo
* bar
</render> |
| </render>
| sub | table |
| --- | <render>
| tiny | innermost | table |
| a | b | c |
| d | e | f |
| g | h | i |
</render> |
</render> || <render>
%INCLUDE{"Sandbox.TestIncludeArea"}%
</render> |
shall render:
| foo | bar | foobar |
| more foo |
more bar |
|
| sub | table |
| --- |
| tiny |
innermost |
table |
| a |
b |
c |
| d |
e |
f |
| g |
h |
i |
|
|
This is a test topic to be included inside a cell of a table
-- FritzBosch - 03 Dec 2001
|
Formatted Search Example
| *Topic* | *Classification* | *Textfield* | *Textareafield* |
%SEARCH{"TestTextArea" scope="topic" regex="on" nosearch="on" casesensitive="on" web="Sandbox" format="| $web.$topic | $formfield(TopicClassification) | $formfield(Textfield) | <render>
$formfield(Textareafield)
</render> |"}%
shall render:
It is not clear to me why the bullets are not rendered here
--
FritzBosch - 04 Dec 2001
I really like your proposal, it's very general and it should not be too difficult to implement as a Plugin!
Let brainstorm a little ... what if we implement it this way:
- remove the render marked text, put it aside and replace it with a numbered inline marker
%RENDER{1}% (to handle more than one piece)
- render both the external part and the internal ones
- replace the markers with the corresponding rendered parts
I just wonder if this could give rise to mutual recursions with INCLUDEd topcs ...
- Is there any protection against recursion in "normal" includes? I'm scared to break something by trying it. -- FritzBosch - 05 Dec 2001
- Yes, there is ... (though I am not sure about the state of the recursion check for INCLUDE{http://somepage} ) -- AndreaSterbini - 05 Dec 2001
--
AndreaSterbini - 04 Dec 2001
I like the concept but would prefer something shorter and easier to type than
<render>, the whole idea behind wiki in the first place is
quick-quick after all. : )
--
MattWilkie - 04 Dec 2001
You could define a pair of variables in your
WebPreferences:
- Set A = <render> (stands for Alpha)
- Set O = </render> (stands for Omega)
And then use %A% .................................. %O%
(if I remember well, the replacement is made AFTER vars collection)
--
AndreaSterbini - 05 Dec 2001
Maybe an alternate approach could be that you write the included cell data earlier, using something like a flag (let's say
~ for now).
To create a table within a table, you would do this:
~InnerTable
The table above would
not be rendered. It would handle a ~WikiWord (must start at beginning of line) to imply that all data below the flag and up to an empty line would be included later.
Then you would include it in a later table cell:
| Description |
Type/Cost Summary |
| Ball-bearing yield |
~InnerTable |
The nice thing is that you keep the table "clean". The bad thing is that you kind of force people to create things piecemeal.
Comments?
--
DavidWeller - 06 Dec 2001
The syntax is debatable, personally I'd prefer David's proposal.
This is currently not possible, but we could enhance TWiki to allow
TWikiTemplates commands inside a topic, e.g. use
%TMPL:DEF{"var"}% ...
%TMPL:END% to define a block of text (aka an inner table) and
%TMPL:P{"var"}% to print it (inside a cell).
--
PeterThoeny - 06 Dec 2001
Nice idea (template syntax is somewhat unWiki, though).
An added advantage is that such (template) variables
could be used more than once. Nesting should be allowed.
Table Example
%TMPL:DEF{"t_inner"}%
| tiny | innermost | table |
| a | b | c |
| d | e | f |
| g | h | i |
%TMPL:END
%TMPL:DEF{"t_sub"}%
| sub | table |
| --- | %TMPL:P{"t_inner"}% |
%TMPL:END
%TMPL:DEF{"cell_b3"}%
* more
* foo
* bar
%TMPL:END
%TMPL:DEF{"cell_c3"}%
%INCLUDE{"Sandbox.TestIncludeArea"}%
%TMPL:END
| *foo* | *bar* | *foobar* |
|more foo | more bar | %TMPL:P{"cell_b3"}% |
|%TMPL:P{"t_inner"}% || %TMPL:P{"cell_c3"}% |
Formatted Search Example
Oops! How would this be entered?
--
FritzBosch - 10 Dec 2001
Table Example
Interesting example, Fritz. So let me reiterate the same example in my suggested Wiki-ish format:
~t_inner
| tiny | innermost | table |
| a | b | c |
| d | e | f |
| g | h | i |
~t_sub
| sub | table |
| --- | ~t_inner |
~cell_b3
* more
* foo
* bar
~cell_c3
%INCLUDE{"Sandbox.TestIncludeArea"}%
| *foo* | *bar* | *foobar* |
|more foo | more bar | ~cell_b3 |
| ~t_inner || ~cell_c3 |
Now, doesn't that look "cleaner"?
Personally, I strongly discourage usage of the INCLUDE directive, I think it causes more problems than it solves. But your mileage may vary
--
DavidWeller - 11 Dec 2001
Much cleaner - but IMHO one would have to mark the end of a definition, e.g:
~cell_b3
* more
* foo
* bar
~~
Would such a syntax extension break anything?
What worries me more, though, is the
formatted search example above. I think this could be one of the major uses of such an extension.
How would this work?
--
FritzBosch - 13 Dec 2001
the ~blah ... ~~ syntax could be done pretty easily with a plugin. Here's what I'd do:
- Go through the text in startRenderingHandler, removing all ~blah .. ~~ blocks, and calling (recursively) TWiki::getRenderedVersion on each. Leave the references (inside table cells, etc.) alone!
- Cache the rendered ~blah blocks in a hash by the "blah" identifier.
- When endRenderingHandler is called, substitute all references (still present after rendering) by the rendered version cached in the hash.
--
WalterMundt - 19 Jan 2003
I've written a plugin that implements both ~macros (with ~~ terminator) and the
<render> tag. It's called
RecursiveRenderPlugin. It's a pretty quick job, so it could really use some better testing.
This
is a demonstration of what it can do. Look at the raw code, it's largely similar to the above examples.
--
WalterMundt - 20 Jan 2003