CKHTMLParser

Class/Module:
Class
In:
lib/cgikit.rb
Parent:
Object

Description

CKHTMLParser parses a template of a component. The template is HTML, except one fact that it has "<cgikit>" tag. You can use two types of formats as CGIKit tag, "<cgikit>…</cgikit>" and "<cgikit />". The difference of the formats is whether the tag’s body is empty or not. So, if you write "<cgikit></cgikit>", it has the same meaning as "<cgikit />".

The CGIKit tag has only one attribute, "name". The "name" attribute is a name of CGIKit element. The "name" attribute is composed of "[a-zA-Z0-9_]". You can enclose the value of the "name" attribute by double quotation mark. And, The value is case-sensitive.

For instance, these have the same meaning.

  <cgikit name=foo></cgikit>
  <cgikit name=foo />
  <cgikit name="foo"></cgikit>
  <cgikit name="foo" />

On the other hand, these have different meanings.

  <cgikit name=Foo />
  <cgikit name="foo" />
  <cgikit name=FOO></cgikit>

Comment of HTML is interpreted by CKHTMLParser because it is necessary to include something like CSS and Javascript. If you want to comment out some parts of a template, you use "<!— … —>". The format is like HTML comments, but with an additional hyphen.

  <html>
  <head>
  </head>
  <body>
  <!-- HTML comment. This is interpreted. -->
  <!--- CGIKit comment. This is not interpreted.
    <!-- HTML comment. Because this is in CGIKit comment,
         this is not also interpreted. -->
  --->
  </body>
  </html>

As the template is explained in the example, the first HTML comment is interpreted and the second HTML comment is not interpreted.

CGIKit comment is not allowed to be nested. So, the next example is not allowed.

  <!--- foo bar
   <!--- foo bar --->
  --->

Methods

each_block_string
new
parse

Attributes

application [RW]
html_string [RW]
parent [RW]
repetition_index [RW]
repetitions [RW]

Classes and Modules

Class CKHTMLParser::CKHTMLParseError

Public Class Methods

new( parent, string )

Public Instance Methods

each_block_string() {|str, :comment| ...}
parse()