How do I...Use the Transformations/Transform Content menu item?

Table of contents
No headers

There is an edit menu item called Transformations or Transform Content depending upon which skin you are using. The purpose of this Transformations or Tranform Content menu item is to allow you to attach a Dekiscript function to HTML elements (mostly <pre> elements). The content of these elements is then sent to the extension function for tranformation. Content transforms include: syntax highlighting, graphviz graph scripts, mathematical expressions, silverlight, spoiler text, etc.

How are "content transforms" different from regular DekiScript functions? Each content transform is a function, but not each function is a transform. The function has to explicitly declare itself to be a content transform and identify to which HTML elements it's applicable.

You must  already have encoded the content to be transformed in a <pre></pre> element. Select the content to be transformed and you will see a dropdown box listing the available transformations in the installation of MindTouch Deki that you are using.  Choose the transformation you wish to use, select it and the content will be transformed according to the function which was selected.  Selecting "Transformations" or "Transform Content" for items which are not in <pre></pre> elements will result in the display of "No Transformations" in the drop down box and no transformation will be performed.

Creating a new content transform is as easy as registering a new extension in the Services Management Console of the Control Panel.

Here is an example using some php code:

Transformations Menu.png

Highlighting the php code in the <pre></pre> section, select Transformations and choose syntax.Php results in the following:

<?php
/**
 * Smarty plugin
 * @package Smarty
 * @subpackage plugins
 */

/**
 * Get seconds and microseconds
 * @return double
 */
function smarty_core_get_microtime($params, &$smarty)
{
    $mtime = microtime();
    $mtime = explode(" ", $mtime);
    $mtime = (double)($mtime[1]) + (double)($mtime[0]);
    return ($mtime);
}

/* vim: set expandtab: */

?>

  

Tag page
Viewing 2 of 2 comments: view all
I don't understand what this function does. I've tried to use it on test pages, but since I don't really know what I'm going to get if it works, I can't tell if I've used it correctly. And the example you give with the PHP code doesn't help at all; you show me PHP code in a box, and then you show me PHP code not in a box, so what did the "transformation" do? Maybe links to other pages that explain what components are would help since I find I spend a lot of time looking up other terms to try to understand a given paragraph.
Posted 21:04, 24 Nov 2008
Did you notice the difference in style between the two boxes? The first box was a simple <pre> box, which has nothing more than a fixed width page. However, the second box shows the PHP code with color highlights and line numbers. So that's what this does!
Posted 23:28, 24 Nov 2008
Viewing 2 of 2 comments: view all
You must login to post a comment.