Skip to content

Commit

Permalink
Adding template files, updating readme
Browse files Browse the repository at this point in the history
  • Loading branch information
maccettura committed Nov 16, 2023
1 parent 1f5d6c4 commit 27b5e94
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 1 deletion.
24 changes: 24 additions & 0 deletions OptiScaffold/TemplateFiles/BlockComponentTemplate.tmp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using EPiServer;
using EPiServer.Core;
using EPiServer.Web.Mvc;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;

namespace {featureNamespace}.{type}.{className}
{
public class {className}Component : AsyncBlockComponent<{className}>
{
private readonly IContentLoader _contentLoader;

public {className}Component(IContentLoader contentLoader)
{
_contentLoader = contentLoader;
}

protected override async Task<IViewComponentResult> InvokeComponentAsync({className} currentBlock)
{
var model = new {className}ViewModel(currentBlock);
return await Task.FromResult(View("~/Features/{type}/{className}/{className}.cshtml", model));
}
}
}
11 changes: 11 additions & 0 deletions OptiScaffold/TemplateFiles/BlockViewModelTemplate.tmp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using {blockVmNamespace};

namespace {featureNamespace}.{type}.{className}
{
public class {className}ViewModel : {blockVmClass}<{className}>
{
public {className}ViewModel({className} currentBlock) : base(currentBlock)
{
}
}
}
1 change: 1 addition & 0 deletions OptiScaffold/TemplateFiles/BlockViewTemplate.tmp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@model {featureNamespace}.{type}.{className}.{className}ViewModel
10 changes: 10 additions & 0 deletions OptiScaffold/TemplateFiles/PageControllerTemplate.tmp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using EPiServer.Web.Mvc;
using Microsoft.AspNetCore.Mvc;

namespace {featureNamespace}.{type}.{className}
{
public class {className}Controller : PageController<{className}>
{
public ActionResult Index({className} currentContent) => View(ContentViewModel.Create<{className}>(currentContent));
}
}
15 changes: 15 additions & 0 deletions OptiScaffold/TemplateFiles/PageOrBlockOptiTemplate.tmp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using EPiServer.Core;
using EPiServer.DataAbstraction;
using EPiServer.DataAnnotations;
using System.ComponentModel.DataAnnotations;
using {abstractNamespace};

namespace {featureNamespace}.{type}.{className}
{
[ContentType(DisplayName = "{cmsname}",
GUID = "{guid}",
Description = "{cmsname}")]
public class {className} : {abstractClassName}
{
}
}
20 changes: 20 additions & 0 deletions OptiScaffold/TemplateFiles/PageViewModelTemplate.tmp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using EPiServer.DataAbstraction;
using System.Linq;
using {abstractNamespace};
using {pageVmNamespace}

namespace {featureNamespace}.{type}.{className}
{
public class {className}ViewModel : {pageVmClass}<{className}>
{
public {className}ViewModel({className} currentPage) : base(currentPage)
{
}

public static {className}ViewModel Create({className} currentPage)
{
var model = new {className}ViewModel(currentPage);
return model;
}
}
}
1 change: 1 addition & 0 deletions OptiScaffold/TemplateFiles/PageViewTemplate.tmp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@model {featureNamespace}.{type}.{className}.{className}ViewModel
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

## ⚡️ Quick start


Install using the dotet tool install via your favorite terminal: `dotnet tool install --global OptiScaffold`

## ⚙️ How to use

Expand Down

0 comments on commit 27b5e94

Please sign in to comment.