Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 31 additions & 33 deletions TagScriptEngine/block/case.py
Original file line number Diff line number Diff line change
@@ -1,56 +1,54 @@
from typing import Optional

from ..interface import verb_required_block
from ..interface import Block
from ..interpreter import Context

class UpperBlock(Block):
"""Converts the given text to uppercase.

class UpperBlock(verb_required_block(True, payload=True)):
"""
Converts the given text to uppercase.

**Usage:** ``{upper:<string>}``
**Usage:** ``{upper([text]))}``

**Aliases:** ``upper``
**Aliases:** ``uppercase, upper``

**Payload:** ``string``
**Payload:** None

**Parameter:** ``None``
**Parameter:** text

**Examples: **
**Examples:** ::

.. tagscript::
The text is {lower(ThIs Is A TeXt)}!
# The text is THIS IS A TEXT!

{upper:ThiS is A Text}
# THIS IS A TEXT
You have entered {lower({args})}!
# You have entered HELLO WORLD!
"""

ACCEPTED_NAMES = "upper"
ACCEPTED_NAMES = ("upper","uppercase")

def process(self, ctx: Context) -> Optional[str]:
return ctx.verb.payload.upper()
def process(self, ctx: Context) -> str:
text = str(ctx.verb.parameter).upper()
return "" if text == "NONE" else text

class LowerBlock(Block):
"""Converts the given text to lowercase.

class LowerBlock(verb_required_block(True, payload=True)):
"""
Converts the given text to lowercase.

**Usage:** ``{lower:<string>}``
**Usage:** ``{lower([text])}``

**Aliases:** ``lower``
**Aliases:** ``lowercase, lower``

**Payload:** ``string``
**Payload:** None

**Parameter:** ``None``
**Parameter:** text

**Examples: **
**Examples:** ::

.. tagscript::
The text is {lower(ThIs Is A TeXt)}!
# The text is this is a text!

{upper:ThiS is A Text}
# this is a text
You have entered {lower({args})}!
# You have entered hello world!
"""

ACCEPTED_NAMES = "lower"
ACCEPTED_NAMES = ("lower","lowercase")

def process(self, ctx: Context) -> Optional[str]:
return ctx.verb.payload.lower()
def process(self, ctx: Context) -> str:
text = str(ctx.verb.parameter).lower()
return "" if text == "none" else text