This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- To combine with https://gist.github.com/DanDiplo/30528387da41332ff22b --> | |
<script> | |
const renderULLI = (data) => `<ul>${data.map(li => `<li>${li}</li>`).join('')}</ul>`; | |
document.body.innerHTML=renderULLI(['Hi!','line2','line 3']) | |
</script> | |
<!-- might be improved for template updates with https://github.com/Polymer/lit-html --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Code examples of using my QueryStringHelper c# class for parsing query string values | |
// See https://github.com/DanDiplo/QueryString-Helper | |
QueryStringHelper qs1 = new QueryStringHelper(Request.QueryString); // initialise from Request.QueryString | |
string query = "?page=5&username=dan&year=2010&enabled=true&email=dan@example.com&option=apple&option=banana&option=melon&date=2015/07/06"; | |
QueryStringHelper qs = new QueryStringHelper(query); // intialise from string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// JS array equivalents to C# LINQ methods - by Dan B. | |
// Here's a simple array of "person" objects | |
var people = [ | |
{ name: "John", age: 20 }, | |
{ name: "Mary", age: 35 }, | |
{ name: "Arthur", age: 78 }, | |
{ name: "Mike", age: 27 }, | |
{ name: "Judy", age: 42 }, | |
{ name: "Tim", age: 8 } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Inspired by several web solutions and https://raw.githubusercontent.com/aspnet/Mvc/133dd964abb1c2a4167cf38faa38fe0319b7b931/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewFeatures/ViewResultExecutor.cs | |
public class ViewToStringRendererService: ViewExecutor | |
{ | |
private ITempDataProvider _tempDataProvider; | |
private IServiceProvider _serviceProvider; | |
public ViewToStringRendererService( | |
IOptions<MvcViewOptions> viewOptions, | |
IHttpResponseStreamWriterFactory writerFactory, | |
ICompositeViewEngine viewEngine, |