lektor_ng.types.fake

src/lektor_ng/types/fake.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from lektor_ng.constants import PRIMARY_ALT
from lektor_ng.i18n import get_i18n_block
from lektor_ng.types.base import Type


class FakeType(Type):
    def value_from_raw(self, raw):
        return None

    def to_json(self, pad, record=None, alt=PRIMARY_ALT):
        rv = Type.to_json(self, pad, record, alt)
        rv["is_fake_type"] = True
        return rv


class LineType(FakeType):
    widget = "f-line"


class SpacingType(FakeType):
    widget = "f-spacing"


class InfoType(FakeType):
    widget = "f-info"


class HeadingType(FakeType):
    widget = "f-heading"

    def to_json(self, pad, record=None, alt=PRIMARY_ALT):
        rv = FakeType.to_json(self, pad, record, alt)
        rv["heading_i18n"] = get_i18n_block(self.options, "heading")
        return rv