CKComponent

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

Description

When you define your component, its class must inherit CKComponent in code file. The component dynamically renders HTML with template and binding file.

A component has 3 files in a directory whose name is the same as the component’s name. These three files composite Model-View-Controller architecture.

Template(View):A HTML file includes CGIKit tags ( <cgikit> ). One CGIKit tag corresponds to one dynamic element.
Binding(Controller):A definition file for elements is used by a component. The suffix, ckd, is abbreviation of "CGIKit Definition". The definition file connects Template to Code.
Code(Model):A Ruby source where a component’s class is defined. It must inherit CKComponent. The name of the component’s class must be the same as the component name.

ex) An application with a MainPage component

 /cgi-bin/cgikit-app
   cgikit-app.cgi
   /MainPage
     MainPage.html
     MainPage.ckd
     MainPage.rb

Programming Topics

Methods

access_instance_variables?
convert_char_code
definition_file
definition_string
init
new
page
parse_ckd_value
post_action
pre_action
request
resource_manager
response
run
session
template_file
template_string
to_s
variable?

Attributes

definitions [RW]
Hash of definitions in a binding file of the component.
is_top [RW]
path [R]
Path for structual files of the component.

Classes and Modules

Class CKComponent::FileNotFoundError

Included modules

CKKeyValueCoding

Public Class Methods

access_instance_variables?()

Enables accessing instance variables directly with value(), take_value().

new( app, parent, name, body, path = nil )

Public Instance Methods

convert_char_code( values )

Hook method to convert character code for the form values.

definition_file()

Returns name of the definition( binding ) file.

definition_string()

Returns body of the definition( binding ) file as string.

init()

Hook method for initialization instead of initialize(). Form data is not setted when the method is called.

page( page )

Creates a specified page component.

parse_ckd_value( string )

Internal method.

post_action()

Hook method called after run() that are setting form data and invoking action.

pre_action()

Hook method called after setting form data, before invoking action.

request()

Returns a request object of the application.

resource_manager()

Returns a resource manager object.

response()

Returns a response object of the application.

run()

Invokes the action after binding component’s variables to attributes for definitions, values from request to component’s variables.

session()

Returns the session object. If the session isn’t existed, returns a new session.

template_file()

Returns name of the template file.

template_string()

Returns body of the template file as string.

to_s()

Converts the component to HTML.

variable?( string )

Internal method.