0

I’m building ASP.NET Core application, and have a requirement that some pages (not for all pages), will be generated on the fly from fragments. Fragments will be stored in database and include pieces of JavaScript and HTML code. The fragments should be inserted in certain places, and there must be a way to pass parameters to the fragments.

HTML page
<div class="row">
@insert_fragment_with_parameters(fragmentId = 1, parameters: {day:”Friday”} 
)
…

Fragment 1
<h2>Good morning. Today is @insert_parameter(day) </h2>
…


Fragment 2
…

I have a feeling that I’m inverting a wheel here. Is there any notation/library/framework to achieve this fast and easy?

maverick_2
  • 13
  • 4
  • Does your organization prohibit the use of razor pages? Is there technical reason why you cannot use razor pages? – Jeffrey Rennie Oct 11 '18 at 03:03
  • Fragments will be stored in database, not in the file system. I want this engine to work not only in asp.net mvc or web-api application, but also in a separate unit test project. Currently I’m trying to understand if I can use Razor for that. – maverick_2 Oct 15 '18 at 06:40
  • Besides Razor is a way too slow and overkill for the task. I'm looking into [Scriban](https://github.com/lunet-io/scriban) now – maverick_2 Oct 29 '18 at 05:16

0 Answers0