Uploaded image for project: 'LaTeX'
  1. LaTeX
  2. LATEX-49

Make it simpler to replace some default template content from a custom template

    XMLWordPrintable

Details

    • Improvement
    • Resolution: Won't Fix
    • Major
    • None
    • 1.6
    • Syntax
    • None
    • Unknown
    • N/A
    • N/A

    Description

      A best practice when using a custom template is to do search/replace of content so that when the default template is upgraded you can still benefit from it and only modify what you need.

      In order to make this simpler, I'm introducing new methods in ModifiableTemplate:

      • public void replaceLines(String match, String replacement)
      • public void replaceLines(String match, String replacement, boolean useRegex)
      • public void replaceLine(String match, String replacement)
      • public void replaceLine(String match, String replacement, boolean useRegex)

      Example usage in a custom Preamble template:

      ## This is testing an override showing how to replace some default content with some other content
      ## Step 1: Get the default template
      #set ($template = $latex.processor.getTemplate('default/Preamble'))
      ## Step 2: Replace the content
      #set ($discard = $template.replaceLine('\usepackage{amsmath}', '\usepackage{amsmath, amsthm, amssymb, amsfonts}'))
      ## Step 3: Render the modified template
      $latex.processor.render($template)##
      

      Attachments

        Activity

          People

            vmassol Vincent Massol
            vmassol Vincent Massol
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: