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

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

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Won't Fix
    • Affects Version/s: 1.6
    • Fix Version/s: None
    • Component/s: Syntax
    • Labels:
      None
    • Difficulty:
      Unknown
    • Documentation:
      N/A
    • Documentation in Release Notes:
      N/A
    • Similar issues:

      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

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

              Dates

              • Created:
                Updated:
                Resolved: