About
Here you will find the definition for the main concepts introduced in comp library.
Jinja
A jinja inner variable is a variable in the jinja syntax of a jinja string which is defined inside the jinja string by making use of the
[% set ... %]block. Those variables can be accessed through the attribute.inner_varsofJinjaor through the typed functionjinja_inner_vars.
A jinja free variable is a variable in the jinja syntax of a jinja string which is not defined inside the jinja string. Their values should be included in the jinja context in order to render the jinja string. They can be accessed through the attribute
.free_varsofJinjaor through the typed functionjinja_free_vars.
The jinja context of a jinja string is a Python dictionary whose keys are the free jinja vars of the jinja string.
In the context of jinja strings, jinja rendering is the process of turning them into raw HTML by giving a jinja context.
A jinja factory is a type factory taking values into a subtype of the
Jinjatype. An example isTag: Tuple(Str) -> TYPE, which assigns to a tuple of strings the subtype ofJinjaconsisting of those jinja strings which are delimited by the HTML tag named by some of the strings in the given tuple.
Components
A component is a typed function decorated with the
@componentdecorator and that returns a subtype ofJinja: the type of jinja strings. Components form the typeCOMPONENT. Components are typically structured by some component model.
The local context of a component is that defined by the special variable
__context__.
A leak of a component is a jinja free var on its underlying jinja string which is not declared in the {lib:local context}.
A bounded component is a component without leaks. In other words, it is a component such that every jinja free var is declared in the {lib:local context}.
A content variable in a component is a variable of type
Content, which is given byUnion(Str, Extension('md', 'rst')). These variables represent static content (MarkdownofReStructuredText) to be included somewhere in a component.
A component factory is a type factory that takes values into some subtype of
COMPONENT. It is, therefore, a parameterized family of components. The main component factory isCOMPONENT, when viewed as a callable entity. Other example isTAG, which receive strings*tagsand build the subtypeTAG(*tags)ofCOMPONENTgiven by the components taking values inTag(*tags).
A tag component is a component whose jinja string is encapsulated in some HTML tag block, hence that take values into the image of the jinja factory
Tag. In other words, a tag component is an instance ofTAG(*tags)for some*tags.
A component operation is a typed function that receive components and return other component.
The component join is a component operation
join: Tuple(COMPONENT) -> COMPONENTthat receive components*compsand return the new componentjoin(*comps)whose jinja string is the string join of the corresponding jinja strings.
The component concat is a component operation
join: Prod(COMPONENT(1),COMPONENT) -> COMPONENTthat evaluates the inner var of a component with the jinja string of other component.
Rendering
Rendering is the process of turning a component into raw HTML by means of providing a rendering context and fixing {lib:rendering flags}. It is implemented as a typed function
render.
The rendering context is the information needed to be attached to a component in order to render it. This includes, for example, values for any component variable any component leak.
The rendering flags are special {py:arguments} of the
rendertyped function, which configures the rendering process. Examples are:__styled__,__minified__, and so on.
The rendering style is a special feature of the component rendering process in which style strings are automatically introduced as css classes in a
<style>tag of the produced HTML.
A style string is a string representing a css class, used as values to the attribute
<comp>_classof a component, and which are converted to the css class they represent during the rendering process. Typically the css class is composed by a single css property, so that the style string is named based into a style property. For example,margin-top-10pxis a style string with a single style property:margin-top.
A style property is a css property inside the css class represented by a style string.
A given css class can be represented by multiples style strings. Given a style string, the other style strings represented the same css class are style aliases for the given one. When the style string corresponds to a style property, then their style aliases are constructed from aliases for the underlying style property. For example, the style string
margin-top-10pxcorresponds to the style propertymargin-top, which havemtas an aliases, defining the style aliasmt-10px.