
Aramid: Create Strongly-Typed HTML Components in C# - douche
https://github.com/edamtoft/Aramid
======
hyperlinq
You may want to check out Hyperlinq, a C# library for statically typed HTML
generation. It also statically types the HTML attributes. Example code:

H.head ( H.title ("Hello world"), H.link (a => a.href ("/favicon.ico").rel
("shortcut icon").type ("image/x-icon")) )

Having used it on a website that I've had to maintain for years I can say that
the simplicity of writing reusable components and ease of refactoring is
really nice. It entirely negates the need to use a view mechanism at all - you
just write your views in C# code.

The links for github and nuget are:

[https://github.com/hyperlinq/hyperlinq](https://github.com/hyperlinq/hyperlinq)
[https://www.nuget.org/packages/Hyperlinq](https://www.nuget.org/packages/Hyperlinq)

I should mention that I use Hyperlinq in conjunction with MarkdownDeep.
Markdown is great for defining HTML fragments that are very document-oriented,
as opposed to data-oriented. So for instance I'd use markdown to define an
FAQ, but would use Hyperlinq to define HTML for a customer record. Markdown
fragments can be inserted into a Hyperlinq DOM as literal nodes (the
underlying mechanism for Hyperlinq is Linq to XML), so the two approaches mesh
together nicely.

I wrote the library ages ago but put very little effort into promoting it as
I'm too busy.

------
ZenoArrow
WebSharper templates are worth considering as an alternative:

[https://github.com/intellifactory/websharper.ui.next/blob/ma...](https://github.com/intellifactory/websharper.ui.next/blob/master/docs/Templates.md)

[https://kimsereyblog.blogspot.co.uk/2016/08/create-html-
comp...](https://kimsereyblog.blogspot.co.uk/2016/08/create-html-componants-
for-your.html)

------
haimez
I like the idea, but I think this kind of thing feels obtuse in languages like
C# and Java where the "templates" are 100% written with the hosted language.

Some languages can work around this by having flexible type definitions and
syntax to make the DSL much closer to the target template (for an example,
see: [http://www.lihaoyi.com/scalatags/](http://www.lihaoyi.com/scalatags/)).
This works pretty well to avoid all those field declaration and "new"
keywords.

~~~
wtetzner
> I like the idea, but I think this kind of thing feels obtuse in languages
> like C# and Java where the "templates" are 100% written with the hosted
> language.

I agree, but it's not that bad. I do think j2html [1] has a cleaner look than
Aramid.

[1] [http://j2html.com/](http://j2html.com/)

------
jeremy_wiebe
Looks a lot like the HtmlTags project that grew out of FubuMvc.

[https://github.com/HtmlTags/htmltags](https://github.com/HtmlTags/htmltags)

------
SBArbeit
In .NET Core, there are new TagHelpers that probably do some of the same
stuff... not sure exactly of the overlap, but I've used them and they're
really nice.

~~~
simooooo
I'd much rather use razor than write all my markup in c#. This code looks way
too bloated

------
3dGrabber
While the _tags_ are strongly typed, their _attributes_ are apparently not
(anonymous types). Why?

------
throwaway98237
I feel the name should be "Kevlar" to reflect use of trademarks by Microsoft
and DuPont. Perhaps if the language used was C++ then Aramid might be
appropriate.

------
isuckatcoding
Is this only for server side rendering?

------
partycoder
Why not F#?

~~~
junkyarddog
Using F# would have been a great choice. By using algebraic data types plus
active patterns the size of the code base would have been dramatically reduced
and much more comprehensible. And of course it would have been even more type
safe.

