Ticket #617 (closed enhancement: wontfix)

Opened 4 years ago

Last modified 12 months ago

raw view macro

Reported by: psd Owned by: FND
Priority: trivial Milestone: 2011.cleanup
Component: core Version:
Severity: trivial Keywords: view macro
Cc:

Description

In RippleRap?, we use a "raw" mode to the "view text" macro to display HTML imported from the Flickr RSS feed as-is:

<pre>{{blog_item{<<view text raw>>}}}</pre>

 http://svn.tiddlywiki.org/Trunk/contributors/PaulDowney/plugins/RawViewMacroPlugin.js

config.macros.view.views.raw = function(value,place,params,wikifier,paramString,tiddler) {
                createTiddlyElement(place,"span",null,null).innerHTML = value;
        };

There may be a better name for the view than "raw", but it does seem like a worthy addition to the core.

Attachments

ticket617.patch Download (0.5 KB) - added by FND 4 years ago.
N.B.: using DIV instead of SPAN

Change History

in reply to: ↑ description   Changed 4 years ago by EricShulman

Without any extra param (other than the fieldname, of course), the view macro shows the value "as-is" (in other words, as plain, unparsed *text*)

<<view fieldname>>

If you add the "wikified" keyword, it parses and renders the value as TW wiki-syntax content:

<<view fieldname wikified>>

I would suggest using a keyword of "html" to parse and render the text as HTML content:

<<view fieldname html>>

Changed 4 years ago by FND

N.B.: using DIV instead of SPAN

follow-up: ↓ 3   Changed 4 years ago by FND

  • owner changed from JeremyRuston to FND
  • status changed from new to assigned

in reply to: ↑ 2   Changed 4 years ago by EricShulman

I recommend using a SPAN instead of a DIV. Otherwise, there is no way to use the <<view fieldname html>> syntax to insert content inline since DIV will always force a linebreak.

follow-up: ↓ 5   Changed 4 years ago by FND

I understand the issue here, but I still think that using a SPAN is problematic (block elements within an inline element). Nevertheless, I would understand if SPAN were chosen over DIV in order not to confuse users.

in reply to: ↑ 4   Changed 4 years ago by EricShulman

Block elements occur within inline elements all the time! If a block element occurs, a newline is started... if no block element, then no forced newline. Consider the following TW usage:

before <<view fieldname html>> after

if the html contained in fieldname does not use any block elements (let's say it's just an <a href="..."> element), then the result might appear, all on one line, as:

before  http://www.example.com/ after

Now, consider if the html consists of "some text" followed by a small table, and then "some more text". Then the result would be:

before some text

Cell 1Cell 2Cell 3
Cell 4Cell 5Cell 6

some more text after

Lastly, if the author *wants* the HTML to occur on a separate line, they can always explicitly enter the content as:

before
<<view fieldname html>>
after

or even

before {{block{<<view fieldname html}}} after

where 'block' is a custom CSS classname defined as:

.block { display:block; }

resulting in:

before
some text

Cell 1Cell 2Cell 3
Cell 4Cell 5Cell 6

some more text
after

Thus, using a SPAN within the macro handler gives greater flexibility in formatting, but does not prevent the use of a DIV if one is desired.

  Changed 4 years ago by FND

According to the  specs, inline elements should "contain only data and other inline elements".

However, as stated above, convenience might override correctness in this case.

Another option would be to use a DIV with a class like "rawContainer" defining display: inline;.

If further discussion is required, we should probably move this to [twdev].

  Changed 3 years ago by FND

  • milestone changed from 2.5.1 to 2.6

  Changed 18 months ago by MartinBudden

  • milestone changed from 2.6.2 to 2.7.1

Milestone 2.6.2 deleted

  Changed 12 months ago by MartinBudden

  • status changed from assigned to closed
  • resolution set to wontfix
  • milestone changed from 2.7.1 to 2011.cleanup

Functionality can be added as a plugin by those who require it. Not a core feature, especially since the DIV/SPAN issue not resolved.

Note: See TracTickets for help on using tickets.