cheat sheets for code templates

Are you missing a feature? Request its implementation here.
jomclaughlin
Posts: 1
Joined: Tue Dec 21, 2010 9:19 pm

cheat sheets for code templates

Post by jomclaughlin »

Hi,
Do you guys have printable cheat sheets for code templates? I searched around the web site and didn't see anything. This would be quite helpful for noobs like me.
adrian
Posts: 2855
Joined: Tue May 17, 2005 4:01 pm

Re: cheat sheets for code templates

Post by adrian »

Hello,

I'm afraid we don't have something like this on the site.
But I'll see if we can generate a code templates "cheat sheet" for you.

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
george
Site Admin
Posts: 2095
Joined: Thu Jan 09, 2003 2:58 pm

Re: cheat sheets for code templates

Post by george »

Hi,

The code templates can be exported as an XML file from Options->Preferences -- Editor / Templates / Code Templates -- Export.

Then you can just write a simple XSLT stylesheet to generate a cheat sheet with the information you like in the format you like. As an example the stylesheet below generates a simple HTML cheat sheet:

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:template match="/">
<html>
<head>
<title>Cheat sheet</title>
</head>
<body>
<xsl:for-each-group select="//codeTemplateItem"
group-by="field[@name='contentType']/String">
<h1>
<xsl:text>Templates for </xsl:text>
<xsl:value-of select="current-grouping-key()"/>
</h1>
<table border="1">
<tr bgcolor="AAAAAA">
<th>Name</th>
<th>Description</th>
</tr>
<xsl:apply-templates select="current-group()">
<xsl:sort select="field[@name='renderString']/String"/>
</xsl:apply-templates>
</table>
</xsl:for-each-group>
</body>
</html>
</xsl:template>
<xsl:template match="codeTemplateItem">
<tr bgcolor="{if (position() mod 2 = 0) then 'DDDDFF' else 'FFFFDD'}">
<td><xsl:value-of select="field[@name='renderString']/String"/></td>
<td><xsl:value-of select="field[@name='descriptionString']/String"/></td>
</tr>
</xsl:template>
</xsl:stylesheet>
Best Regards,
George
George Cristian Bina
Post Reply