Alias (via AliasPlugin) to make shortcuts for HTML codes, possible?

75 views
Skip to first unread message

G.J.Robert

unread,
Aug 22, 2012, 10:06:04 PM8/22/12
to tiddl...@googlegroups.com
Hi there,

I'm trying to play with the capabilities of AliasPlugin [1]. So far, I have been successful to make aliases as shortcuts to smileys like
<<alias :) [img[smile]]>> (where the tiddler smile is an uploaded image via TiddlySpace)
or as shortcuts to simplify complex syntaxes like
<<alias pop @@position:relative;+++^30em^[%0]%1===@@>> (prerequisite: NestedSlidersPlugin; where the "position:relative" is a trick to make the floatingPanel right under the button on TiddlySpace)

I was trying to extend the usage of alias shortcuts further by defining aliases to render HTML snippets. For example, as with a div with an image as its background, the HTML code would be something like:
<div style="background-image: url(http://domain.com/image.jpg); width: XXXpx; height: YYYpx;>abracadabra</div>
and I hope to use an alias
<<alias imgdiv "<div style="background-image: url(%0); width: %1px; height: %2px;>%3</div>">>
so that I can just type
<<imgdiv http://url.of.the/image XXX YYY abracadabra>>
to create the same div as above.

However, in my experiment, when I put this <<imgdiv>> in the <html>...</html> statement block (with HTMLFormattingPlugin installed, for TiddlyWiki syntax to be mixed within the HTML block), the alias just throws out the text of <div style="background-image: url(http://domain.com/image.jpg); width: XXXpx; height: YYYpx;>abracadabra</div> (with the URL wikified!), but not making the real div element.

I've also tried to make a simpler alias to insert <p>0%</p>, and again, only the literal <p>Parameter input</p> is rendered.

Is it ever possible to make aliases substituting working HTML elements instead of displaying the literal codes?

(I have also tried to make aliases as shortcuts to insert something like "rowspan='%0'" to help simplify the syntax of MediaWikiTableFormatterPlugin [2], also in vain. I guess it's because the aliases cannot be rendered *before* the formatters?)

[1] http://www.tiddlytools.com/#AliasPlugin
[2] http://devpad.tiddlyspot.com/#MediaWikiTableFormatterPlugin

Tobias Beer

unread,
Aug 23, 2012, 4:29:15 AM8/23/12
to tiddl...@googlegroups.com
Would putting the html wrapper in your alias definition work?

<<alias imgdiv "<html><div style="background-image: url(%0); width: %1px; height: %2px;>%3</div></html>">>

Cheers, Tobias.

G.J.Robert

unread,
Aug 24, 2012, 9:25:14 AM8/24/12
to tiddl...@googlegroups.com
Wow Dear Lord it's working~ It never occurred to me to work around this way.

Thanks a lot Tobias, you guys rock~ :D

Tobias Beer於 2012年8月23日星期四UTC+8下午4時29分15秒寫道:
Reply all
Reply to author
Forward
0 new messages