On 5/22/07, Mattias Gaertner <[EMAIL PROTECTED]> wrote:
> of a unit) etc.. I've seen some pretty cool custom templates designed
> by the community.
Can you give examples?
Sure, here is a few from the tiOPF project.
BTW: For technical details about the xml format have a look at:
http://delphi.wikia.com/wiki/Live_Templates_Technical_Info
This one can only be triggered in a method body...
-------------[InheritedGetItems.xml]----------------
<?xml version="1.0" encoding="utf-8" ?>
<codetemplate
xmlns="http://schemas.borland.com/Delphi/2005/codetemplates"
version="1.0.0">
<template name="igi" invoke="auto">
<point name="resulttype">
<hint>
Result type
</hint>
<text>
TtiObject
</text>
</point>
<description>
inherited GetItems(i) as TtiObject;
</description>
<author>
Peter Hinrichsen
</author>
<code language="Delphi" context="methodbody"
delimiter="|"><![CDATA[result:= inherited GetItems(i) as
|resulttype|;]]>
</code>
</template>
</codetemplate>
-------------------[end]------------------------------------
Here is one defining a TtiObjectList class. Looking at it now, I
think they got the 'context=" setting wrong. I emailed them to confirm
this.
--------------------[tiObjectList.xml]-----------------------------
<?xml version="1.0" encoding="utf-8" ?>
<codetemplate
xmlns="http://schemas.borland.com/Delphi/2005/codetemplates"
version="1.0.0">
<template name="tiol" invoke="auto">
<description>
TtiObjectList template;
</description>
<author>
Peter Hinrichsen
</author>
<point name="objectclass">
<hint>
Object's class
</hint>
<text>
TMyObject
</text>
</point>
<point name="objectparent">
<hint>
Object's parent
</hint>
<text>
TMyParent
</text>
</point>
<point name="itemclass">
<hint>
Item's class
</hint>
<text>
TMyItem
</text>
</point>
<code language="Delphi" context="methodbody" delimiter="|">
<![CDATA[
|objectclass| = class(TtiObjectList)
private
protected
function GetItems(i: integer): |itemclass|; reintroduce;
procedure SetItems(i: integer; const AValue: |itemclass|); reintroduce;
function GetParent: |objectparent|; reintroduce;
public
property Items[i:integer] : |itemclass| read GetItems write SetItems;
procedure Add(AObject : |itemclass|); reintroduce;
property Parent: |objectparent| read GetParent;
published
end;
]]>
</code>
</template>
</codetemplate>
--------------------[end]--------------------------
Here is a nice and simple one, fixing the formatting of the 'exit'
identifier in code
--------------------------------[exit.xml]------------------------------------
<?xml version="1.0" encoding="utf-8" ?>
<codetemplate
xmlns="http://schemas.borland.com/Delphi/2005/codetemplates"
version="1.0.0">
<template name="ex" invoke="auto">
<description>
Exit; //==>;
</description>
<author>
Peter Hinrichsen
</author>
<code language="Delphi" context="methodbody" ><![CDATA[Exit;
//==>]]>
</code>
</template>
</codetemplate>
----------------------------------[end]----------------------------------------
--
Graeme Geldenhuys
General error, hit any user to continue.
_________________________________________________________________
To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives