示例#1
0
def fill(context, mapping, args):
    if not (1 <= len(args) <= 4):
        raise error.ParseError(_("fill expects one to four arguments"))

    text = stringify(args[0][0](context, mapping, args[0][1]))
    width = 76
    initindent = ''
    hangindent = ''
    if 2 <= len(args) <= 4:
        try:
            width = int(stringify(args[1][0](context, mapping, args[1][1])))
        except ValueError:
            raise error.ParseError(_("fill expects an integer width"))
        try:
            initindent = stringify(args[2][0](context, mapping, args[2][1]))
            initindent = stringify(
                runtemplate(context, mapping,
                            compiletemplate(initindent, context)))
            hangindent = stringify(args[3][0](context, mapping, args[3][1]))
            hangindent = stringify(
                runtemplate(context, mapping,
                            compiletemplate(hangindent, context)))
        except IndexError:
            pass

    return templatefilters.fill(text, width, initindent, hangindent)
def fill(context, mapping, args):
    if not (1 <= len(args) <= 4):
        raise error.ParseError(_("fill expects one to four arguments"))

    text = stringify(args[0][0](context, mapping, args[0][1]))
    width = 76
    initindent = ''
    hangindent = ''
    if 2 <= len(args) <= 4:
        try:
            width = int(stringify(args[1][0](context, mapping, args[1][1])))
        except ValueError:
            raise error.ParseError(_("fill expects an integer width"))
        try:
            initindent = stringify(_evalifliteral(args[2], context, mapping))
            hangindent = stringify(_evalifliteral(args[3], context, mapping))
        except IndexError:
            pass

    return templatefilters.fill(text, width, initindent, hangindent)
def fill(context, mapping, args):
    if not (1 <= len(args) <= 4):
        # i18n: "fill" is a keyword
        raise error.ParseError(_("fill expects one to four arguments"))

    text = stringify(args[0][0](context, mapping, args[0][1]))
    width = 76
    initindent = ''
    hangindent = ''
    if 2 <= len(args) <= 4:
        try:
            width = int(stringify(args[1][0](context, mapping, args[1][1])))
        except ValueError:
            # i18n: "fill" is a keyword
            raise error.ParseError(_("fill expects an integer width"))
        try:
            initindent = stringify(_evalifliteral(args[2], context, mapping))
            hangindent = stringify(_evalifliteral(args[3], context, mapping))
        except IndexError:
            pass

    return templatefilters.fill(text, width, initindent, hangindent)
示例#4
0
def fill(context, mapping, args):
    """:fill(text[, width[, initialident[, hangindent]]]): Fill many
    paragraphs with optional indentation. See the "fill" filter."""
    if not (1 <= len(args) <= 4):
        # i18n: "fill" is a keyword
        raise error.ParseError(_("fill expects one to four arguments"))

    text = stringify(args[0][0](context, mapping, args[0][1]))
    width = 76
    initindent = ''
    hangindent = ''
    if 2 <= len(args) <= 4:
        try:
            width = int(stringify(args[1][0](context, mapping, args[1][1])))
        except ValueError:
            # i18n: "fill" is a keyword
            raise error.ParseError(_("fill expects an integer width"))
        try:
            initindent = stringify(_evalifliteral(args[2], context, mapping))
            hangindent = stringify(_evalifliteral(args[3], context, mapping))
        except IndexError:
            pass

    return templatefilters.fill(text, width, initindent, hangindent)
示例#5
0
def fill(context, mapping, args):
    """:fill(text[, width[, initialident[, hangindent]]]): Fill many
    paragraphs with optional indentation. See the "fill" filter."""
    if not (1 <= len(args) <= 4):
        # i18n: "fill" is a keyword
        raise error.ParseError(_("fill expects one to four arguments"))

    text = stringify(args[0][0](context, mapping, args[0][1]))
    width = 76
    initindent = ''
    hangindent = ''
    if 2 <= len(args) <= 4:
        try:
            width = int(stringify(args[1][0](context, mapping, args[1][1])))
        except ValueError:
            # i18n: "fill" is a keyword
            raise error.ParseError(_("fill expects an integer width"))
        try:
            initindent = stringify(args[2][0](context, mapping, args[2][1]))
            hangindent = stringify(args[3][0](context, mapping, args[3][1]))
        except IndexError:
            pass

    return templatefilters.fill(text, width, initindent, hangindent)