Skip navigation.

Log in | Sign up

Linux for Designers

a blog by Eckhard M. Jäger

gEdit Template plugin

, , , ,

For SweeTS i needed the possibilty to create a document based on a template file (the normal "New from template" function). gEdit didn't ship with that and so i tried to create it. I was lucky to find a start in the familiar plugin by Rob Miller which i modified. This plugin is completely localized in german and english.

How it works:
* Copy the files of the Template plugin into ~/.gnome2/gedit/plugins
* create a folder "templates" in ~/.gnome2/gedit
* copy your templates files into it (example default.html)
* Start gEdit and enable the plugin "New File From a Template" in the preferences
* After a restart the plugin appears in the File menu
* Assign the typical shortcut "Shift+Ctrl+N" to it
* the new created files will get the mimetype of the template files

Download:
http://files.myopera.com/area42/files/gedit_template_plugin.zip

gEdit plugins i wrote too:
http://my.opera.com/area42/blog/gedit-language-reference-plugin
http://my.opera.com/area42/blog/gedit-browser-preview-plugin
A lot of other gEdit plugins can be found here.

Second Life WindLight First Look ViewerGimp 2.4.2

Comments

Anonymous 28. November 2007, 04:02

engel writes:

Great template! I've just released a basic template set for this: http://hansengel.wordpress.com/2007/11/27/gedit-template-plugin-basic-templates/

It includes most templates that web developers would need.

area42 28. November 2007, 07:47

Hello Engel,

very cool, i will check it out!

Anonymous 28. November 2007, 13:37

engel writes:

I have a suggestion for this plugin....

Why not make support for "variables", like the current user logged in? Then, we could reference the variables from our templates through brackets (ex. "{user}"). The plugin would process the template, and replace the variables with their values.

area42 28. November 2007, 18:10

a possibel way, i will think about that.

Anonymous 26. July 2008, 07:49

TompaD writes:

Hi!

I have a problem with one of your plugins - template-plugin.
The dialogwindow will not close after I have choosed a template.
Its an template I made myself(actionscript)....when I choose
another the window close....strange.


Regards
TompaD

area42 26. July 2008, 10:20

@TompaD
Can i download it and take a look? Or drop me a line: bart neeeneenee de

Anonymous 1. August 2008, 09:12

TompaD writes:

I made a new one with mxml-extension, but the same there, no closing of window after clicking OK.

It looks like this:














regards

Tompad

area42 1. August 2008, 10:36

Here no problem at all. What's the filename of it? Did it contains spaces? Try to use "_" for spaces.

Anonymous 2. August 2008, 07:37

Tompad writes:

How strange!
The filenames is Flex.mxml and Actionscript3.as - I tried with different files...
So no spaces...Is it because I run it on Xubuntu?? ...but when none of the templates should work......the "original" templates loads as they should.....this is a mysterium for me.....


Anonymous 2. August 2008, 08:31

TompaD writes:

Hi again!

I tried to make other template - TXT.txt, DOC.doc and PHP5.php - and guess what!
Only PHP5.php did work as the "original" templates. Is there a list in the plugin with which files is accepted?

Anonymous 2. August 2008, 08:40

TompaD writes:

Hi again! :-)

What is the latest version of plugin?
I got 1.02.

Regards
TompaD

area42 2. August 2008, 09:04

1.02 is up-to-date. What kind OS and desktop you use? Which version of gEdit?

Anonymous 2. August 2008, 09:31

TompaD writes:

Lets see - I have Xubuntu 8.04 with Xfce 4 Desktop Environment
version 4.4.2 (Xfce 4.4), gEdit is 2.22.3

alexs 21. October 2008, 17:10

Danke für das Plugin, eine Vorlage zu öffnen fehlte mir von PSPad sehr. (sidux mit xfce-Desktop)
Jetzt muss ich nur noch schauen dass ich den Color-Picker (nicht das ganze Paket) zum laufen bekomme.

Grüsse Alexs

area42 21. October 2008, 20:38

@Alexs

Hier gibt es noch mehr Plugins für gEdit:
http://live.gnome.org/Gedit/Plugins#third_party

Und unbedingt die Snippet-Sammlung für das Externe Werkzeuge-Plugin ansehen:
http://live.gnome.org/Gedit/ExternalToolsPluginSnippets

Anonymous 2. May 2009, 10:03

Felix writes:

I think this is somewhat broken in gEdit 2.26.1 (Ubuntu 9.04). The part that's broken seems to be the language detection of the template. I just deleted that whole part and it worked.
But thanks, great plugin :)

area42 6. May 2009, 21:22

Hi Felix,

you are right, i got a brand new Dell Studio 17 and will install Jaunty on it, then i will fix this problem.

Anonymous 7. May 2009, 06:36

konsumer writes:

I made a version that uses ~/Templates (to share with nautilus) and uses some variables:

$$DATETIME$$
$$YEAR$$
$$USER_EMAIL$$
$$USER_NAME$$
$$USER_NICKNAME$$

It grabs this data from the gnome "About Me" dialog.

You can see how to add them by searching for "add some useful presets" in template.py

I also included templates for Druapl6 module, and some others I find useful.

http://david.konsumer.googlepages.com/gedit_template_plugin.zip

area42 7. May 2009, 19:33

Hi konsumer,

this sound great. Did it working on Ubuntu 9.04?

alexs 11. May 2009, 16:19

Irgendwie klappt das Plugin nicht mehr. :worried:
Wenn ich eine HTML-Vorlage mit gedit 2.26.1 öffnen will (sidux), steht folgendes in der Konsole:
Traceback (most recent call last):
File "/home/alex/.gnome2/gedit/plugins/template.py", line 145, in on_open_from_template_activate
language = gedit.language_manager_get_language_from_mime_type(language_manager, mimes[0])
AttributeError: 'module' object has no attribute 'language_manager_get_language_from_mime_type'

Grüße Alexs

area42 11. May 2009, 20:43

Hello Alex,

yes i know there is a problem with the gEdit Template plugin. I switched now to Ubuntu 9.04 that ships with Gnome 2.26 and will fix this problem soon.

Thanks for your reply.

Anonymous 11. May 2009, 22:43

konsumer writes:

area42: yes, I am using jaunty.

alex: I didn't touch the language stuff (I don't think.) By the error message, it looks like you are using an older version (I notice there is old language stuff commented out at line 145) Try a new version, try switching around the commented stuff in that area. Maybe comment all the language stuff. what happens?

th3pr0ph3t 19. May 2009, 20:03

Hey I modified this plugin with some of the fixes you guys did (if only I read all the comments *before*).

Anyway, I want to share it and the modifications I did include:
- the language thing where the template is not loaded because it tries to call a method that does not exist anymore.
- the plugin now ASKS now asks for the NEW DOCUMENT's name (starting in the currently open file's directory). It copies the file, then opens it.
- it does not fail (showing an empty document) when the template uses an encoding different than UTF-8 (I needed ISO-8859-1).
- the following expressions are resolved if found in the template text:
$USER $USERNAME, $LOGNAME
$HOME
...and all vars replaced by os.path.expandvars()
$DATE
$TIME
$DATETIME
$GEDIT_CURRENT_DOCUMENT_URI
$GEDIT_CURRENT_DOCUMENT_NAME
$GEDIT_CURRENT_DOCUMENT_PATH
$GEDIT_CURRENT_DOCUMENT_DIR

Well that's the way I like it, maybe somebody else does.
Here's the file, regards.

http://files.myopera.com/th3pr0ph3t/files/template.zip

area42 20. May 2009, 07:34

I will check it out!!! Thanks.

How to use Quote function:

  1. Select some text
  2. Click on the Quote link

Write a comment

Comment
(BBcode and HTML is turned off for anonymous user comments.)

Type the two words displayed in the image below:


Smilies