Template Toolkit: Библиотеки: Библиотека Splash!

Template Toolkit

(русская редакция)

[ Пособия ] [ Руководство ] [ Модули ] [ Библиотеки ] [ Утилиты ] [ Вопросы ] [ Релиз ] [ Perl-ресурсы ] Форум ]
 
Поиск
Template Toolkit | Библиотеки | Splash | Библиотека Splash!

Библиотека Splash!

[ ◄ Библиотека HTML ] [ Библиотека PostScript ► ]
Библиотека шаблонов для построения стильных пользовательских HTML интерфейсов.

Оглавление

ОПИСАНИЕ

Индекс ] [ Библиотеки ] [ Наверх ]

ПРЕДУПРЕЖДЕНИЕ: Это неполная, устаревшая и неточная документация. Библиотека Splash! находится в стадии разработки и изменения. Смотрите примеры, чтобы получить более точное и новое представление об использовании библиотеки.

Введение

Библиотека шаблонов 'Splash' поставляется в составе Template Toolkit. Ее можно найти в подкаталоге 'templates' установочного каталога.

    /your/tt2/installation
    |
    +-- docs
    |      ...
    |
    +-- images
    |      ...
    |
    +-- examples
    |      ...
    |
    +-- templates
        |
        +-- html
        |      ...
        +-- pod
        |      ...
        +-- splash     <<<< ЭТО ЗДЕСЬ
               ...

Перед использованием библиотеки Splash необходимо сообщить Template Toolkit где искать файлы шаблонов.

    use Template;
    my $tt2 = Template->new({
	INCLUDE_PATH => '/usr/local/tt2/templates',
    });

Для переносимости можно использовать метод класса 'Template::Config->instdir()', чтобы определить каталог, в который установлена библиотека 'templates'.

    use Template;
    my $tt2 = Template->new({
	INCLUDE_PATH => Template::Config->instdir('templates'),
    });

Обратите внимание, что в INCLUDE_PATH должен быть установлен каталог 'templates', как показано выше, а не каталог 'templates/splash', как вы можете захотеть сделать. Многие из компонентов Splash! используют элементы в каталоге 'html' и содержать директивы такого вида:

    [% INCLUDE html/something %].

Конфигурация

The 'splash/config' template defines a 'splash' hash array which contains numerous configuration items for the Splash library. You must PROCESS this template to ensure that the hash definition is imported into your calling template. An INCLUDE is not sufficient as it localises variables and prevents the 'splash' hash array from existing outside the splash/config template.

    [% PROCESS splash/config %]

Alternately, you can define the splash/config template as a PRE_PROCESS item when you create the Template processor.

    use Template;
    my $tt2 = Template->new({
	INCLUDE_PATH => Template::Config->instdir('templates'),
	PRE_PROCESS  => 'splash/config',
    });

You can modify the default configuration by creating your own PRE_PROCESS config file which loads the 'splash/config' and then tweaks the settings to your own preferences.

    my $tt2 = Template->new({
	INCLUDE_PATH => [ '/home/abw/tt2/templates',
		          Template::Config->instdir('templates') ],
        PRE_PROCESS => 'config'
    });

/home/abw/tt2/templates/config:

    [% # load the 'splash' configuration
       PROCESS splash/config;

       # tweak values to personal preferences
       splash.images       = '/~abw/tt2/images/splash'
       splash.select.col   = 'leaf'
       splash.unselect.col = 'bud'
    %]

The splash/config file includes some instructional comments on things you might like to tweak.

Цвета

The Splash! library uses the colours defined in the html/rgb template. The 'rgb' hash defined therein is imported as the 'splash.rgb' hash.

    [% INCLUDE splash/box col='grey75' %]

See the examples for further enlightenment on using colour.

Стиль

There are two very primitive "styles" implemented called "select" and "unselect". These are used to indicate which item on a menu is selected, for example. Each style defines characteristics like background colour, font face, size and colour, text alignment, and so on.

The styles are implemented as hashes within the 'splash' hash. Many of the components respond to a 'style' variable being set and you can pass a direct reference to splash.select or splash.unselect (or your own styles). e.g.

    [% INCLUDE splash/button
	   content = "Unselected"
           style   = splash.unselect
    %]
    [% INCLUDE splash/button
           content ="Selected"
           style   = splash.select
    %]

Alternately, you can use the 'select' variable to indicate either of the inbuilt styles: splash.select or splash.unselect.

    [% INCLUDE splash/button
           content = "Unselected"
           select  = 0
    %]
    [% INCLUDE splash/button
           content = "Selected"
           select  = 1
    %]

ШАБЛОНЫ КОМПОНЕНТОВ

Индекс ] [ Библиотеки ] [ Наверх ]

This section describes some of the component templates in the Splash! library. This documentation is incomplete and may also be inaccurate in places. The examples in the 'examples' directory are likely to be a much better reference.

splash/text

Simple template to format text according to a selected/unselected style, adding links, etc.

    [% INCLUDE splash/text
           content = 'Template Toolkit'
           link    = 'http://www.template-toolkit.org'
           select  = 0
           bold    = 1
    %]

Configuration items:

  • content

    Text content.

  • link

    URL which can be defined to make the text a link.

  • style

    Reference to a style hash.

  • select

    Flag to default the style to splash.select (select == true value) or splash.unselect (select == false value).

The following items default to the relevant style values:

  • col (style.col.text)
  • font (style.font.face)
  • bold (style.font.bold)
  • size (style.font.size)

splash/table

A thin wrapper around html/table, allowing a colour to be specified by name.

    [% WRAPPER splash/table
           col   = 'aqua'
	   pad   = 4
           width = '100%'
    %]
    <tr>
      <td>Foo</td>
      <td>Bar</td>
    </tr>
    [% END %]

Configuration items:

  • content

    Table content.

  • col

    Background colour.

  • border

    Border width (default: 0)

  • width

    Width in absolute pixels (e.g. '100') or as a percentage (e.g. '50%').

  • pad

    Cell padding.

  • space

    Cell padding.

splash/row

Creates a row for an HTML table.

    [% WRAPPER splash/table %]
       [% WRAPPER splash/row col='marine' %]
       <td>Foo</td><td>Bar</td>
       [% END %]
       [% WRAPPER splash/row col='aqua' %]
       <td>Foo</td><td>Bar</td>
       [% END %]
    [% END %]

Configuration items:

  • content

    Row content.

  • col

    Background colour.

  • valign

    Vertical alignment

  • rowspan

    Number of rows to span.

splash/cell

Creates a cell for an HTML table.

    [% WRAPPER splash/table + splash/row + splash/cell col='grey75' %]
	Hello World
    [% END %]

Configuration items:

  • content

    Cell content.

  • col

    Background colour.

  • align

    Horizontal alignment

  • colspan

    Number of columns to span.

splash/box

A box created from a union of splash/table, splash/row and splash/cell. The following is equivalent to the previous example.

    [% WRAPPER splash/box col='grey75' %]
	Hello World
    [% END %]

Configuration items are as per the individual templates.

splash/button

Creates a small button with rounded corners.

    [% INCLUDE splash/button
           content = 'Template Toolkit'
           select  = 1
           width   = '50%'
    %]

Configuration items:

  • content

    Button content.

  • style

    Reference to a style hash.

  • select

    Flag to default the style to splash.select (select == true value) or splash.unselect (select == false value).

  • width

    Width in absolute pixels (e.g. '100') or as a percentage (e.g. '50%').

The following items default to the relevant style values:

  • col (style.col.text)
  • textcol (style.col.text)
  • font (style.font.face)
  • size (style.font.size)
  • bold (style.font.bold)
  • width (style.button.width)
  • align (style.button.align)

splash/bar

Creates a bar with rounded corners at either the top or bottom, and square corners on the other. Default has rounded at the top, set 'invert' to select bottom.

    [% INCLUDE splash/bar
           content = 'Hello World',
           select  = 1
    %]	

Configuration items:

  • content

    Bar content.

  • style

    Reference to a style hash.

  • select

    Flag to default the style to splash.select (select == true value) or splash.unselect (select == false value).

  • width

    Width in absolute pixels (e.g. '100') or as a percentage (e.g. '50%').

  • invert

    Flag to invert bar to hang down instead of sitting upright.

The following items default to the relevant style values:

  • col (style.col.text)
  • textcol (style.col.text)
  • font (style.font.face)
  • size (style.font.size)
  • bold (style.font.bold)
  • width (style.button.width)
  • align (style.button.align)

splash/hair

Generates a frame enclosing the content within crosshair corners.

    [% INCLUDE splash/hair
           content = 'Template Toolkit'
    %]

Configuration items:

  • content

    Hair content.

  • style

    Reference to a style hash.

The following items default to the relevant style values:

  • col (style.col.text)
  • bgcol (style.col.back)
  • align (style.button.align)

splash/menu

Creates a menu as a series of splash/button elements.

    [% buttons = [
	  { text => 'One', link => 'one.html' }
          { text => 'Two', link => 'two.html' }
       ]
    %]
    [% INCLUDE splash/menu
           select = 2		# Two
    %]

Configuration items:

  • buttons

    A reference to a list of hash arrays containing 'text' and 'link' items.

  • select (n or 0)

    Indicates which button should be selected. First item is 1. 0 indicates no button selected.

  • width

    Width in absolute pixels (e.g. '100') or as a percentage (e.g. '50%').

  • align

    Horizontal alignment

splash/menubar

As above, but incorporated into a wider bar.

    [% WRAPPER splash/menubar %]
       Section Title
    [% END %]

Configuration items:

  • buttons

    A reference to a list of hash arrays containing 'text' and 'link' items.

  • select (n or 0)

    Indicates which button should be selected. First item is 1. 0 indicates no button selected.

  • width

    Width in absolute pixels (e.g. '100') or as a percentage (e.g. '50%').

  • align

    Horizontal alignment

splash/panel

A table with a coloured edge.

    [% WRAPPER splash/panel edge='black' fill='grey75' border=2 %]
       <tr>
         <td>Hello World</td>
       </tr>
    [% END %]

Configuration items:

  • content

    Panel content.

  • style

    Reference to a style hash.

  • select

    Flag to default the style to splash.select (select == true value) or splash.unselect (select == false value).

  • width

    Width in absolute pixels (e.g. '100') or as a percentage (e.g. '50%').

  • align

    Horizontal alignment

  • border

    Border width (default: 0)

The following items default to the relevant style values:

  • edge (style.col.edge)
  • fill (style.col.fill)
  • pad (style.pad)

splash/pane

A union of splash/row + splash/cell.

    [% WRAPPER splash/panel select=1 %]
       [% WRAPPER splash/pane col='grey75' %]
          Hello World
       [% END %]
       [% WRAPPER splash/pane col='grey50' %]
          Hello Again
       [% END %]
    [% END %]

splash/tab

A simple button looking like a page tab.

    [% INCLUDE splash/tab
           content = 'Option 1'
           col = 'aqua'
    %]

Configuration items:

  • content

    Tab content.

  • style

    Reference to a style hash.

  • select

    Flag to default the style to splash.select (select == true value) or splash.unselect (select == false value).

  • width

    Width in absolute pixels (e.g. '100') or as a percentage (e.g. '50%').

  • align

    Horizontal alignment

The following items default to the relevant style values:

  • col (style.col.text)
  • textcol (style.col.text)
  • font (style.font.face)
  • size (style.font.size)
  • bold (style.font.bold)
  • tabalign (style.tab.align)

splash/tabset

A set of splash/tab components, similar to a menu.

Configuration items:

  • tabs

    List of hash references containing text/link entries, as per menu buttons.

  • select

    Flag to default the style to splash.select (select == true value) or splash.unselect (select == false value).

  • invert

    Flag to invert tab to hang down instead of sitting upright.

splash/tabbox

Add a splash/tab to the top of a splash/box.

Configuration items:

  • title
     title.
  • content
     content.
  • width

    Width in absolute pixels (e.g. '100') or as a percentage (e.g. '50%').

  • tabwidth

    Width of tabs.

  • select

    Flag to default the style to splash.select (select == true value) or splash.unselect (select == false value).

  • border

    Border width (default: 0)

The following items default to the relevant style values:

  • col (style.col.text)
  • fill (style.col.fill)
  • tabalign (style.tab.align)
  • tablocate (style.tab.locate)

splash/tabsbox

Add a splash/tabset to the top of a splash/box.

Configuration items:

  • tabs

    List of hash references containing text/link entries, as per menu buttons.

  • select

    Flag to default the style to splash.select (select == true value) or splash.unselect (select == false value).

  • content
     content.
  • width

    Width in absolute pixels (e.g. '100') or as a percentage (e.g. '50%').

  • border

    Border width (default: 0)

  • invert

    Flag to invert to hang down instead of sitting upright.

The following items default to the relevant style values:

  • col (style.col.text)
  • fill (style.col.fill)
  • tabalign (style.tab.align)
  • tablocate (style.tab.locate)

splash/tabspanel

As per splash/tabsbox, but attached to a splash/panel instead of a splash/box.

ПРИМЕРЫ

Индекс ] [ Библиотеки ] [ Наверх ]

Всеобъемлющие примеры использования библиотеки Splash! можно найти в подкаталоге 'examples' установочного каталога.

АВТОР

Индекс ] [ Библиотеки ] [ Наверх ]

Энди Уардли (Andy Wardley <abw@andywardley.com>)

http://www.andywardley.com/

ВЕРСИЯ

Индекс ] [ Библиотеки ] [ Наверх ]

2.70, поставляется в составе Template Toolkit версии 2.14, дата релиза - 4 октября 2004.

АВТОРСКИЕ ПРАВА

Индекс ] [ Библиотеки ] [ Наверх ]

  Copyright (C) 1996-2004 Andy Wardley.  All Rights Reserved.
  Copyright (C) 1998-2002 Canon Research Centre Europe Ltd.

Этот модуль является свободно-распространяемым программным обеспечением; вы можете распространять и/или модифицировать его на тех же условиях, что и Perl.

СМОТРИ ТАКЖЕ

Индекс ] [ Библиотеки ] [ Наверх ]