Class: Yast::HTMLClass

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

Instance Method Summary (collapse)

Instance Method Details

- (Object) Bold(text)

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



207
208
209
# File '../../src/modules/HTML.rb', line 207

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

- (Object) ColoredList(items, color)

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



166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# File '../../src/modules/HTML.rb', line 166

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

- (Object) Colorize(text, color)

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



193
194
195
# File '../../src/modules/HTML.rb', line 193

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

- (Object) Heading(text)

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



65
66
67
# File '../../src/modules/HTML.rb', line 65

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



80
81
82
# File '../../src/modules/HTML.rb', line 80

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

- (Object) List(items)

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

[ul] [li]… [li]… … [/ul]

Parameters:

  • items (Array<String>)

    list of strings for items

Returns:

  • HTML code



140
141
142
143
144
145
146
147
148
149
150
151
# File '../../src/modules/HTML.rb', line 140

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

- (Object) ListEnd

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



108
109
110
# File '../../src/modules/HTML.rb', line 108

def ListEnd
  "</ul>"
end

- (Object) ListItem(text)

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



123
124
125
# File '../../src/modules/HTML.rb', line 123

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

- (Object) ListStart

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



94
95
96
# File '../../src/modules/HTML.rb', line 94

def ListStart
  "<ul>"
end

- (Object) main



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

def main
  textdomain "base"
end

- (Object) Newline

Make a forced HTML line break

Returns:

  • HTML code



216
217
218
# File '../../src/modules/HTML.rb', line 216

def Newline
  "<br>"
end

- (Object) Newlines(count)

Make a number of forced HTML line breaks

Parameters:

  • count (Fixnum)

    how many of them

Returns:

  • HTML code



226
227
228
229
230
231
232
233
234
# File '../../src/modules/HTML.rb', line 226

def Newlines(count)
  html = ""

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

- (Object) Para(text)

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 '../../src/modules/HTML.rb', line 50

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