Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

templater: add pad/truncate functions #4672

Merged
merged 4 commits into from
Oct 20, 2024
Merged

Commits on Oct 18, 2024

  1. text_util: add function to pad labeled text

    This could be inlined in templater implementation, but I decided to add
    text_util functions for ease of testing.
    yuja committed Oct 18, 2024
    Configuration menu
    Copy the full SHA
    8109275 View commit details
    Browse the repository at this point in the history
  2. revset: extract helper that parses function call

    I'm going to add keyword arguments support to templater.
    yuja committed Oct 18, 2024
    Configuration menu
    Copy the full SHA
    612981f View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    ae1a707 View commit details
    Browse the repository at this point in the history
  4. templater: add pad/truncate functions

    As I said in the preceding patch, I settled on separate pad/truncate functions
    instead of a function taking multiple optional parameters. It's less efficient
    to process truncation and padding independently, but I don't think that would
    matter.
    
    The order of arguments follows the current f(..., content) convention. We can
    also add a method syntax, but I'm not sure if it's useful. In order to call a
    method of Template type, we'll need to coerce printable object to Template:
    
      concat(author.email()).truncate_end(10).pad_end(10)
      ^^^^^^
      String -> Template
    
    FWIW, String type could provide more efficient truncate/pad methods.
    
    Closes martinvonz#3183
    yuja committed Oct 18, 2024
    Configuration menu
    Copy the full SHA
    1b1edb6 View commit details
    Browse the repository at this point in the history