Template loses first line

English main discussion
Post Reply
  • Author
  • Message
Offline
Posts: 47
Joined: Fri Mar 27, 2015 7:46 am

Template loses first line

Post by Akuro »

What I did:
Placed a small text file (UTF-8, no BOM) - into the template-folder.

What happens:
I generate a new file from this "template" - from within Akelpad
But the first line is missing. Is this on purpose?
Anything I am doing wrong?

Offline
Posts: 2247
Joined: Tue Aug 07, 2007 2:03 pm
Location: Vinnitsa, Ukraine

Post by FeyFre »

Akuro
Yes, it is. First string will contain "caret placeholder". When you create new document from template you may want set caret into specific position of template. For this purpose exists "caret placeholder" - the sequence of characters. During creation of new file plugin will remove all entries of "caret placeholder" from template text and place caret into position of first entry of it in template text. All built-in templates are use this feature.

Offline
Posts: 47
Joined: Fri Mar 27, 2015 7:46 am

Post by Akuro »

Thank you FeyFre,

Actually, I was wondering whether I could make Akelpad remember the caret position. Can you tell me how to enter that information into a template? Or point me to resources explaining it?

Offline
Posts: 2247
Joined: Tue Aug 07, 2007 2:03 pm
Location: Vinnitsa, Ukraine

Post by FeyFre »

Akuro
Here is example, which is included in distribution:

Code: Select all

<!--CARET-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
	<head>
		<title><!--CARET--></title>
		<meta http-equiv="content-type" content="text/html; charset=utf-8">
	</head>
	<body>

	</body>
</html>
As you can see, first line of file is "<!--CARET-->". It is "caret placeholder". Then, line 5. "<title><!--CARET--></title>". Template plugin will insert text of template file into editor(w/o 1st line), then it will search for all entries of "<!--CARET-->" in inserted text, and remove them. Next it will set care position to 1st entry of "<!--CARET-->" - inside title tags, so you ready to enter title of page.



IF you want remember position of caret in files you edit, you should enable it in settings: Setting -> Registry -> Recent files -> Remember caret position. It is built-in into AkelPad function, independent of any plugins.

Offline
Posts: 47
Joined: Fri Mar 27, 2015 7:46 am

Post by Akuro »

FeyFre
Thanks a ton for the explanation.
The option is enabled in Settings -> Registry -> Recent files ->
But I cannot get it to work to remember/ store the wanted caret-position. Prbably because it is not an htm-file, but a plain text file (snippet file, but really nothing but plain text). Oh well,,,,

Offline
Posts: 2247
Joined: Tue Aug 07, 2007 2:03 pm
Location: Vinnitsa, Ukraine

Post by FeyFre »

IF we still talking about Templates, then: you must manually specify caret placeholder in template file. And it can be file of any type/content.

Offline
Posts: 47
Joined: Fri Mar 27, 2015 7:46 am

Post by Akuro »

Ha, now it works. Don't know what went wrong on the first go-around.

Well, anyway, thanks again, FeyFre. I really appreciate it.
Post Reply