Class: Yast::HTMLClass

Inherits:
Module
  • Object
show all
Defined in:
library/wizard/src/modules/HTML.rb

Instance Method Summary collapse

Instance Method Details

#Bold(text) ⇒ Object

Make a piece of HTML code bold

i.e. embed it into [b]...[/b]

You still need to embed that into a paragraph or heading etc.!

Parameters:

  • text (String)

    text to make bold

Returns:

  • HTML code



192
193
194
# File 'library/wizard/src/modules/HTML.rb', line 192

def Bold(text)
  Ops.add(Ops.add("<b>", text), "</b>")
end

#ColoredList(items, color) ⇒ Object

Make a HTML (unsorted) colored list from a list of strings

[ul] [li][font color="..."]...[/font][/li] [li][font color="..."]...[/font][/li] ... [/ul]

Parameters:

  • items (Array<String>)

    list of strings for items

  • color (String)

    item color

Returns:

  • HTML code



155
156
157
158
159
160
161
162
163
164
165
166
167
# File 'library/wizard/src/modules/HTML.rb', line 155

def ColoredList(items, color)
  items = deep_copy(items)
  html = "<ul>"

  Builtins.foreach(items) do |item|
    html = Ops.add(
      html,
      Builtins.sformat("<li><font color=\"%1\">%2</font></li>", color, item)
    )
  end

  Ops.add(html, "</ul>")
end

#Colorize(text, color) ⇒ Object

Colorize a piece of HTML code

i.e. embed it into [font color="..."]...[/font]

You still need to embed that into a paragraph or heading etc.!

Parameters:

  • text (String)

    text to colorize

  • color (String)

    item color

Returns:

  • HTML code



179
180
181
# File 'library/wizard/src/modules/HTML.rb', line 179

def Colorize(text, color)
  Builtins.sformat("<font color=\"%1\">%2</font>", color, text)
end

#Heading(text) ⇒ Object

Make a HTML heading from a text

i.e. embed a text into [h3]...[/h3]

Note: There is only one heading level here since we don't have any more fonts anyway.

Parameters:

  • text (String)

    plain text or HTML fragment

Returns:

  • HTML code



62
63
64
# File 'library/wizard/src/modules/HTML.rb', line 62

def Heading(text)
  Ops.add(Ops.add("<h3>", text), "</h3>")
end

Make a HTML link

For example [a href="..."]...[/a]

You still need to embed that into a paragraph or heading etc.!

Parameters:

  • text (String)

    (translated) text the user will see

  • link_id (String)

    internal ID of that link returned by UserInput()

Returns:

  • HTML code



76
77
78
# File 'library/wizard/src/modules/HTML.rb', line 76

def Link(text, link_id)
  Builtins.sformat("<a href=\"%1\">%2</a>", link_id, text)
end

#List(items) ⇒ Object

Make a HTML (unsorted) list from a list of strings

[ul] [li]...[/li] [li]...[/li] ... [/ul]

Parameters:

  • items (Array<String>)

    list of strings for items

Returns:

  • HTML code



132
133
134
135
136
137
138
139
140
141
# File 'library/wizard/src/modules/HTML.rb', line 132

def List(items)
  items = deep_copy(items)
  html = "<ul>"

  Builtins.foreach(items) do |item|
    html = Ops.add(Ops.add(Ops.add(html, "<li>"), item), "</li>")
  end

  Ops.add(html, "</ul>")
end

#ListEndObject

End a HTML (unsorted) list

For example [/ul]

You might consider using HTML::list() instead which takes a list of items and does all the rest by itself.

Returns:

  • HTML code



102
103
104
# File 'library/wizard/src/modules/HTML.rb', line 102

def ListEnd
  "</ul>"
end

#ListItem(text) ⇒ Object

Make a HTML list item

For example embed a text into [li][p]...[/p][/li]

You might consider using HTML::list() instead which takes a list of items and does all the rest by itself.

Parameters:

  • text (String)

    plain text or HTML fragment

Returns:

  • HTML code



116
117
118
# File 'library/wizard/src/modules/HTML.rb', line 116

def ListItem(text)
  Ops.add(Ops.add("<li><p>", text), "</p></li>")
end

#ListStartObject

Start a HTML (unsorted) list

For example [ul]

You might consider using HTML::list() instead which takes a list of items and does all the rest by itself.

Returns:

  • HTML code



89
90
91
# File 'library/wizard/src/modules/HTML.rb', line 89

def ListStart
  "<ul>"
end

#mainObject



37
38
39
# File 'library/wizard/src/modules/HTML.rb', line 37

def main
  textdomain "base"
end

#NewlineObject

Make a forced HTML line break

Returns:

  • HTML code



200
201
202
# File 'library/wizard/src/modules/HTML.rb', line 200

def Newline
  "<br>"
end

#Newlines(count) ⇒ Object

Make a number of forced HTML line breaks

Parameters:

  • count (Fixnum)

    how many of them

Returns:

  • HTML code



209
210
211
212
213
214
215
216
217
# File 'library/wizard/src/modules/HTML.rb', line 209

def Newlines(count)
  html = ""

  while Ops.greater_than(count, 0)
    html = Ops.add(html, "<br>")
    count = Ops.subtract(count, 1)
  end
  html
end

#Para(text) ⇒ Object

Make a HTML paragraph from a text

i.e. embed a text into * [p]...[/p]

Parameters:

  • text (String)

    plain text or HTML fragment

Returns:

  • HTML code



48
49
50
# File 'library/wizard/src/modules/HTML.rb', line 48

def Para(text)
  Ops.add(Ops.add("<p>", text), "</p>")
end