📜 ⬆️ ⬇️

NHaml. What it is and what it is eaten with.

NHaml is a .NET implementation of the popular Rails Haml . Therefore, first let's try to understand what is Haml . It stands for XHTML Abstraction Markup Language , that is, it is a markup language for simplified XHTML generation. In our arsenal, we already have the means to achieve such goals: XSLT, ASP.NET Web Forms or even better ASP.NET MVC, etc. NHaml provides an alternative way to build your page markup, and if XHTML itself is a rather verbose language, NHaml is permeated with a brevity . Abbreviations, keywords, block designation - everything is aimed at reducing the amount of code while maximizing its clarity. Let's look at the following piece of code:
ASP.NET MVC (vinaigrette from code and html)
<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" AutoEventWireup="true" <br> CodeBehind="List.aspx" Inherits="MvcApplication5.Views.Products.List" Title="Products" %><br><asp:Content ContentPlaceHolderID="MainContentPlaceHolder" runat="server"><br> <h2><%= ViewData.CategoryName %></h2><br> <ul><br> <% foreach (var product in ViewData.Products) { %><br> <li><br> <%= product.ProductName %> <br> <div class="editlink"><br> (<%= Html.ActionLink("Edit", new { Action="Edit", ID=product.ProductID })%>)<br> </div><br> </li><br> <% } %><br> </ul><br> <%= Html.ActionLink("Add New Product", new { Action="New" }) %><br></asp:Content>
The same markup (and having saved the logic of its construction) can be written, and so ...
Read completely...

')

Source: https://habr.com/ru/post/51455/


All Articles