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]…

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

Parameters:

  • text (String)

    text to make bold

Returns:

  • HTML code



198
199
200
# File 'library/wizard/src/modules/HTML.rb', line 198

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=“…”]…[/li
li][font color=“…”]…[/li

/ul

Parameters:

  • items (Array<String>)

    list of strings for items

  • color (String)

    item color

Returns:

  • HTML code



159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# File 'library/wizard/src/modules/HTML.rb', line 159

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

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

  html
end

#Colorize(text, color) ⇒ Object

Colorize a piece of HTML code

i.e. embed it into [font color=“…”]…

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



185
186
187
# File 'library/wizard/src/modules/HTML.rb', line 185

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]…

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



64
65
66
# File 'library/wizard/src/modules/HTML.rb', line 64

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

Make a HTML link

For example [a href=“…”]…

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



78
79
80
# File 'library/wizard/src/modules/HTML.rb', line 78

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



134
135
136
137
138
139
140
141
142
143
144
145
# File 'library/wizard/src/modules/HTML.rb', line 134

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

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

  html
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



104
105
106
# File 'library/wizard/src/modules/HTML.rb', line 104

def ListEnd
  "</ul>"
end

#ListItem(text) ⇒ Object

Make a HTML list item

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

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



118
119
120
# File 'library/wizard/src/modules/HTML.rb', line 118

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



91
92
93
# File 'library/wizard/src/modules/HTML.rb', line 91

def ListStart
  "<ul>"
end

#mainObject



39
40
41
# File 'library/wizard/src/modules/HTML.rb', line 39

def main
  textdomain "base"
end

#NewlineObject

Make a forced HTML line break

Returns:

  • HTML code



206
207
208
# File 'library/wizard/src/modules/HTML.rb', line 206

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



215
216
217
218
219
220
221
222
223
# File 'library/wizard/src/modules/HTML.rb', line 215

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]…

Parameters:

  • text (String)

    plain text or HTML fragment

Returns:

  • HTML code



50
51
52
# File 'library/wizard/src/modules/HTML.rb', line 50

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