On Dec 20, 2006, at 3:50 PM, Jan Erik Moström wrote:
Once in a while I ask myself "How can I insert current date, etc,
when I create a new document from a stationary?"
From what I understand there is no way to create a template that
includes placeholders, am I right or have I missed something all
these years?
Is there someway to do this without writing a script?
jem
Jan,
Here's the gist of it...
( 0 ) Open a blank BBEdit page
( 1 ) Go to (Window -> Palettes -> Clippings)
where you should see a popup menu that corresponds to a set
folders
( 2 ) You should see the "Clippings" palette
|> HTML
|> Univeral Items
( 3 ) Expand the triangle for "Univeral Items" and select "Long Date
and Time"
( 4 ) Click the "insert" button and you should see the results in
"Text Window 1"
When I clicked on mine I got : <b>Thursday, December 21, 2006
(10:09 AM)</b>
( 5 ) Hold down the option key and notice the "insert" button changes
to "edit"
( 6 ) Click on "edit", notice it pulls up a document which contains
"<b>#longdate# (#time#)</b>"
without the quotes. You can edit that document, save it, and
the next time you click "insert"
it will reflect the changes you've made
( 7 ) While you have the "Long Date and Time" still open click on the
(BBEdit page) "TEXT" icon
to reveal the folder containing the "Long Date and Time"
file. You can see the folder is named
"Universal Items" and if you Cmd-Click on the title you can
see where BBEdit stores the "Clippings"
( 8 ) While at the Finder level hit Cmd-UpArrow to open the parent
folder of "Univeral Items"
Create a new folder called "HTML.php" inside your
"Clippings" folder
Now you can store any "PHP" related clippings there.
My "Clippings" folder looks like this :
[Clippings Folder]
Applescript
C Source
CSS
HTML.html
HTML.php
JavaScript
Property Lists
RSS
Universal Items
( 8 ) At the Finder level, select "Long Date and Time", and hit Cmd-D
to duplicate the item. rename it
to whatever you want for example . Call it "Basic Header",
when yo go back to BBedit you will notice that
it is not in the "Clippings" palette. Close the triangle for
"Universal Items" and re-open it. You will
see that now it's there.
( 9 ) Select "Basic Header", hold down the option key, and click
"edit" button, now modify it to suit your needs.
NOTE : Normally before you insert any of the "Clippings" items , it
is best to save the document,
even if it is empty so everything updates correctly.
Otherwise wait until you save it to "update" it.
EXAMPLE ( A )
Here's an example of one "Clipping" called "PHP $_SESSION Begin"
( 1 ) I create a new page and save it to something like
"ShowRecords.php"
( 2 ) Insert "PHP $_SESSION Begin"
( 3 ) Which inserts this (you can copy it and test it) :
#indent#
<?php
session_start();
// +---------+---------+---------+---------+---------+---------
+---------+---------+---------+
// (1500) <[ PHP Session Initialization ]> [ BEGIN ]
// +---------+---------+---------+---------+---------+---------
+---------+---------+---------+
$_pg_filename = "#FILENAME#" ; // Version
[ #yearnum#_#monthnum#_#monthdaynum# ]
$use_local_functions = true ;
if($use_local_functions)
{
// DO NOT LOAD -> require_once ("f_00_session.php") ;
$ses_id = bh_check_session_id ( ) ;
}
else
{
require_once ("f_00_session.php") ;
if(! bh_session_ck_for_user_logout ( )) // Check to see if
the user clicked on the [Logout] button
{
$ses_id = bh_check_session_id ( ) ;
}
}
// +---------+---------+---------+---------+---------+---------
+---------+---------+---------+
// (1500) <[ PHP Session Initialization ]> [ END ]
// +---------+---------+---------+---------+---------+---------
+---------+---------+---------+
require_once ("a_application_cache.php") ;
application_start () ;
?>
( 4 ) Once I insert it from the "Clippings" palette I hit Cmd_Ctrl-U,
and it converts to this :
<?php
session_start();
// +---------+---------+---------+---------+---------+---------
+---------+---------+---------+
// (1500) <[ PHP Session Initialization ]> [ BEGIN ]
// +---------+---------+---------+---------+---------+---------
+---------+---------+---------+
$_pg_filename = "ShowRecords.php" ; // Version
[ 2006_12_21 ]
$use_local_functions = true ;
if($use_local_functions)
{
// DO NOT LOAD -> require_once ("f_00_session.php") ;
$ses_id = bh_check_session_id ( ) ;
}
else
{
require_once ("f_00_session.php") ;
if(! bh_session_ck_for_user_logout ( )) // Check to see if
the user clicked on the [Logout] button
{
$ses_id = bh_check_session_id ( ) ;
}
}
// +---------+---------+---------+---------+---------+---------
+---------+---------+---------+
// (1500) <[ PHP Session Initialization ]> [ END ]
// +---------+---------+---------+---------+---------+---------
+---------+---------+---------+
require_once ("a_application_cache.php") ;
application_start () ;
?>
EXAMPLE ( B )
Here's an example of one "Clipping" called "PHP Function Block"
The file contains this :
( 1 ) Insert "PHP Function Block"
#indent#
function #selstart#function_name#selend# ( $parm1, $parm2 ="xxx",
$parm3 = "yyy")
{
/*
called - function_name ($parm1, "xxx", "yyy") ;
Author : #NAME#
Created : #longdate# : (#creationtime#)
Updated by : #NAME# - [#monthnum#/#monthdaynum#/
#yearnum#](#time#)
+---------+---------+---------+---------+---------+---------
+---------+---------+---------+
Description : INSERT_FUNCTION_DESCRIPTION_HERE
*/
// INSERT_FUNCTION_CONTENT_HERE
} // ©FUNCTION END [function_name]
/* +---------+---------+---------+---------+---------+---------
+---------+---------+---------+ */
( 2 ) Once I insert it from the "Clippings" palette I hit Cmd_Ctrl-U,
and it converts as shown below step ( 5 ) :
( 3 ) Notice that "function_name" will be selected.
( 4 ) Hit Cmd-E followed by Cmd-F followed by TAB and enter the name
you want for the new function
For this exaple I typed "pgsql_SearchRecords"
( 5 ) Type the name of the function you wish to use, and click on the
"Replace All" button, which
will change "function_name" to "pgsql_SearchRecords" in three
places. I can then do the
same for any of the $parms, and can add or delete parameters,
but at least if gives a
starting point. I can even have several "Clippings" that have
a different number and type
of parameters, and call them something like :
"PHP Function Block - 0 parms",
"PHP Function Block - 1 parms",
"PHP Function Block - 2 parms",
"PHP Function Block - 3 parms",
"PHP Function Block - 4 parms"
And that way save a boat-load of time, and get consistent
function blocks
Here's the result after the "update"
function pgsql_SearchRecords ( $parm1, $parm2 ="xxx", $parm3 = "yyy")
{
/*
called - pgsql_SearchRecords ($parm1, "xxx", "yyy") ;
Author : Bill Hernandez
Created : Thursday, December 21, 2006 : (10:46 AM)
Updated by : Bill Hernandez - [12/21/2006](11:08 AM)
+---------+---------+---------+---------+---------+---------
+---------+---------+---------+
Description : INSERT_FUNCTION_DESCRIPTION_HERE
*/
// INSERT_FUNCTION_CONTENT_HERE
} // ©FUNCTION END [pgsql_SearchRecords]
/* +---------+---------+---------+---------+---------+---------
+---------+---------+---------+ */
I have hundreds of these clippings that I use to automate, sometimes
in concert with Applescript to do even more...
Here's an examle of what I have just for "PHP" :
I created these category subfolders, and they each contain several
"Clipping Documents"
HTML.php
PHP Glossary (This I found on the web, it has hundreds of
"Clippings")
PHP_Base (This I found on the web, it also has many
"Clippings")
array
constructs
date/time
dbm
directory
file system
http
if/else
image
mail
math
miscellaneous
mysql
PHP function
print
program execution
regular expressions
string
url
variables
while
PHP_Mine (This I created, and is the one I use the most, it also
has hundreds of "Clippings")
Align
Begin and End Tags
Block Elements
Comments
Debug Statements
Font
Frames
Globals Redefine
Head Elements
Image
Includes
Pages
PlaceHolders
Span
Tables
Terminal
URL Link
I have one for Applescript also, since I do almost all Applescript
editing in BBEdit....
I don't know if this is what you were looking for, but I hope this
was helpful...
Best Regards,
Bill Hernandez
Plano, Texas
--
------------------------------------------------------------------
Have a feature request? Not sure the software's working correctly?
If so, please send mail to <[EMAIL PROTECTED]>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml>
List archives: <http://www.listsearch.com/BBEditTalk.lasso>
To unsubscribe, send mail to: <[EMAIL PROTECTED]>