Pode.Web icon indicating copy to clipboard operation
Pode.Web copied to clipboard

Multiple templates in directory with name "Templates"

Open TFischerIntercope opened this issue 3 years ago • 3 comments

I think it would be nice when the directory "templates" may contain more then one template. So I created a directory "default" and moved the directories "public" and "views" into it and changed these two function

function Get-PodeWebTemplatePath { param( [Parameter()] $Template )

$path = Split-Path -Parent -Path ((Get-Module -Name 'Pode.Web').Path)
return (Join-PodeWebPath (Join-PodeWebPath $path 'Templates') $Template)

}

function Use-PodeWebTemplates { :::: $Title,

    [Parameter()]
    [string]
    $Template,

::: if ([string]::IsNullOrWhiteSpace($Template)) { $Template = 'default' } $templatePath = Get-PodeWebTemplatePath $template

::: }

Now I am able to create a template clone "mytemplate" in "templates" and in my server.ps1 I can call

Use-PodeWebTemplates -Title 'MyServer' -theme Dark -template mytemplate

TFischerIntercope avatar Jun 21 '22 12:06 TFischerIntercope

Hi @TFischerIntercope,

This looks similar to #309, to add support for custom templates 😄

Badgerati avatar Jun 21 '22 20:06 Badgerati

Hi Badgerati, no, it wasn't about changing an element, but about the structure and content of Index.pode. I didn't quite understand why there can only be a single template in the "templates" directory. Maybe there is a more elegant way to duplicate Index.pode

TFischerIntercope avatar Jun 21 '22 22:06 TFischerIntercope

I didn't quite understand why there can only be a single template in the "templates" directory

Mostly because no one has asked for custom templates until now 😜

By extension this and custom elements are the same; if we add support for custom templates in general then this would allow custom index/login pages, elements, and layouts (and any other template types in the future).

Pode.Web will only ever have its templates in that one directory bundled with the module, but it should be possible to make it so you can have your own templates folder at the root of your server (or elsewhere), and tell Pode.Web to use that instead; and be able to do it on a per page/element/layout basis as well. (possibly even the JS/CSS as well 🤔, and allow for complete custom template packs).

Badgerati avatar Jun 23 '22 20:06 Badgerati