question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Variable pass to Scriban example.

See original GitHub issue

Hi!

I am fairly inexperienced with web dev, so some concepts are passing me by. In particular, I have never used (or even heard of) Scriban before.

I have a working version of the website, using a series of html pages loaded at start as such:

ModScriban.Page(Resource.FromAssembly(Path + ".html")).Title(Name);

I am now trying to change variables being passed through at runtime, which I assume is the purpose of the scriban example in the docs (which mentions a ShopModel and Basket variable). I have attempted to implement this in my own way, as so:

public class AIModel : PageModel
  {
      public string DOut { get; }
      public AIModel(IRequest request, IHandler handler, string dOutput) : base(request, handler)
      {
          DOut = dOutput;
      }
  }

//Example of my constructor: 
return ModScriban.Page(Resource.FromAssembly(Path + ".html"), (request, handler) => new AIModel(request, handler, "5"));

This is just a tester, meant to output the string “5” to the area specified on the site. Inside the html file being loaded, I have put two lines (I wasnt sure which variable would be referenced). {{DOut}} {{dOutput}}

In the area of the page where these would show, I am seeing absolutely nothing however. Is my entire flow wrong, or have I just missed a step?

PasteBins Website Constructor Page Constructor HTML

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
DraconInteractivecommented, Jan 21, 2021

Thanks for the info! May do so when I get the chance, but its not high priority, and you have a lot on your hands 😃

1reaction
DraconInteractivecommented, Jan 20, 2021

I had a look at the .zip you provided, the entire process is immediately clearer 😃 I spent some time converting my system to that model, works perfectly!

The project templates sound like a really good idea, i did most of my learning from the Demo template in the .Themes repo.

Good to know its based on bootstrap! I have a small amount of experience with it, so thats a plus 😃

Your help has been massively appreciated here 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

scriban/doc/language.md at master
All argument are passed to the special variable $ that will contain the list of direct arguments and named arguments: $0 or $[0]...
Read more >
C# Scriban - using Scriban template engine in C#
In the next example, we pass two variables to the template engine. Program.cs. using Scriban; var name = "John Doe"; var occupation =...
Read more >
The embedded functions for the Scriban template
The following example shows the Scriban template you could use for the Promo ... that will be passed to the Sitecore field renderer...
Read more >
Solving All Problems With Scriban/C#
However, passing the model as a dictionary of string to object worked well. var model = new Dictionary<string, object>(); model.Add("Args", ...
Read more >
scriban
Parse a scriban template var template = Template. ... Allow to pass a block of statements to a function, typically used by the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found