Skip to content

Probably a small Feature Request: PLASTER_TemplateSource #314

Closed

Description

@schittli

Good morning

Thanks a lot for this really great and useful module, it's a little difficult to work with the generated files, but it's very helpful for own projects.

Unfortunately, Plaster has a very big issue which would be very easy to solve.
If one would like to contribute to complex foreign projects, then it very often takes a long time to find the source template
that belongs to a generated file: We have to grep for similar text, study code and understand the logic - just to get the right template.

Therefore, it would be great if

  1. Plaster could offer a Variable which references the exact path of the used template, for example, PLASTER_TemplateSource or PLASTER_TemplateFileName (…Source is more generic and could later be extended for generated Text which is not based on a Template but just on Code)
  2. Plaster recommends as best practices to always use this Variable in generated files.

This could include the necessary hint in the generated files:

MyFile.ps1
# Generated by Plaster
# Template: xxx

At least for me, it would save hours.
Thanks a lot, kind regards,
Thomas

Activity

  1. LaurentDardenne commented on Mar 28, 2018

    @LaurentDardenne

    You can use this variables :

    PLASTER_TemplatePath - The absolute path to the template directory.
    PLASTER_Version - The version of the Plaster module invoking the template.
    

    Check if PLASTER_TemplatePath still contains the versionning of the container (module/script)?

  2. schittli commented on Mar 28, 2018

    @schittli
    Author

    Hi Laurent,
    Thank you very much for your hint!,
    I saw the PLASTER_TemplatePath variable, but to get just a path still leaves many possibilities and questions open.

    • It would be really useful (or at least not harmful) if Plaster offers the used Template filename, too.
    • Additionally, it would be useful if Plaster sets a good example, uses these variables itself and recommends it as best practices.

    Many projects are hoping for free staff and this simple measure would make it much easier to get started, because many things are built around templates.

    Kind regards, Thomas

  3. LaurentDardenne commented on Mar 28, 2018

    @LaurentDardenne

    It would be really useful (or at least not harmful) if Plaster offers the used Template filename, too.

    The file name is always 'plasterManifest.xml' or 'plasterManifest_(CultureName).xml)'

    This module contains two templates :

    #install-module Templates
    #C:\Program Files\WindowsPowerShell\Modules\Templates\0.2.0\src\NewModuleTemplate\plasterManifest.xml
    #C:\Program Files\WindowsPowerShell\Modules\Templates\0.2.0\src\NewCmdletTemplate\plasterManifest.xml
    

    If you want to indicate the original template, here it would be something like:

    #Template :  Container='Templates'; version= 0.2.0; WhatIsBuilt=NewModule
    #or
    #Template :  WhatIsBuilt=NewModule; @{ModuleSpecification} 
    

    But another solution is to place the information in the file to transform, like here

    Additionally, it would be useful if Plaster sets a good example, uses these variables itself

    I think it was planned, but for the moment I do not know if this project is in sleep because of lack of time of the contributors. I am not the right person to answer that point.

    and recommends it as best practices.

    Localizing is not easy if you do not want to duplicate xml files.
    To do one thing by template file is better, but can we call this a 'good practice'?

  4. rkeithhill commented on Mar 28, 2018

    @rkeithhill
    Collaborator

    I do not know if this project is in sleep because of lack of time of the contributors

    That's a fair assessment. :-) I will get back to the issue backlog but right now am busy on other OSS projects - namely the VSCode extension for PowerShell, PSES and posh-git. BTW thanks @LaurentDardenne for your continued support and help on this project.

    # Generated by Plaster
    # Template: xxx
    

    That's a reasonable ask but IMO it should be put somewhere in each template's source files and not automatically added by Plaster. We'd screw up certain types of files where say # is not a comment e.g. XML files.

    I supposed Plaster could emit some sort of "template fingerprint/info" file but I could see folks getting annoyed by that - having to delete it most of the time so it didn't get committed to version control.

  5. schittli commented on Mar 29, 2018

    @schittli
    Author

    Hi Laurent,
    thank you very much for your support and your explanations!
    Yes, I always forget Localizing... and I enjoy it every day.

    I will start using your proposed code in the opensource projects where I can contribute. It will hopefully work like a virus, so that others are starting to use it, too ;-)

    Kind regards, Thomas

  6. schittli commented on Mar 29, 2018

    @schittli
    Author

    Hi Keith
    thanks a lot for your answer and support, too!,

    Yes, my idea was not that Plaster automatically creates references to the used template in all generated files by itself.

    My idea was that if Plaster also works internally with Plaster templates or if it offers template examples, that these templates includes the source information wherever possible and useful.

    Kind regards, Thomas

  7. schittli commented on Mar 29, 2018

    @schittli
    Author

    Good evening

    The file name is always 'plasterManifest.xml' or 'plasterManifest_(CultureName).xml)'

    That's true, but the Manifest.xml probably isn't the template itself.
    To get useful Information, this is not enough for foreign contributors and it makes their work unnecessarily difficult.

    Example usage in this Project: PowerShell ModuleBuild

    The ModuleBuild Project has a lot of template files. Let's test PLASTER_TemplatePath:

    1. The Template File is:
      C:\…\Modules\ModuleBuild\0.2.2\plaster\ModuleBuild\scaffold\Build.template
    2. The inserted statement is:
      # Used Template: <%=$PLASTER_TemplatePath%>
    3. The generated File: Plaster just inserts the Directory of the Manifest.xml file.
      # Used Template: C:\…\Modules\ModuleBuild\0.2.2\plaster\ModuleBuild

    Result: Unfortunately, the result is almost useless,

    because the declared Directory contains more than 100 files :-(

    Therefore, I keep asking that Plaster sometimes will introduce a Variable to declare the real used template Filename, something like PLASTER_TemplateSource

    Thanks a lot,
    kind regards, Thomas

  8. schittli commented on Mar 29, 2018

    @schittli
    Author

    Good evening

    I've just created a pull request which introduces the new variable PLASTER_TemplateSource:

    Pull request: #316

    It's really hard to contribute to this Module:

    after a long time, I had to stop to try debugging Plaster and I had to add Tracing-Messages. Very annoying.

    If someone could give some starting tips & tricks for contributors, I guess this will be useful :-)

    Kind regards, Thomas

  9. locked and limited conversation to collaborators on Feb 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions