/// <summary> /// Starting point for creating a block of html. /// </summary> /// <returns></returns> public static MailBlockFluent CreateBlock() { var template = MailBodyTemplate.BlockTemplate(); var instance = CreateBody(template, null); return(instance); }
/// <summary> /// Starting point for creating a body with a footer. /// </summary> /// <param name="footer"></param> /// <returns></returns> public static MailBlockFluent CreateBody(MailBlockFluent footer) { var template = MailBodyTemplate.GetDefaultTemplate(); var instance = new MailBlockFluent(template, footer); return(instance); }
/// <summary> /// Generate the html /// </summary> /// <returns></returns> public string GenerateHtml(dynamic attributes = null) { if (_template == null) { _template = MailBodyTemplate.GetDefaultTemplate(); } var builder = new StringBuilder(); foreach (var command in _commands) { builder.Append(command()); } if (_isBlock) { var element = new ContentElement { Content = builder.ToString(), Attributes = attributes }; return(_template.Block()(element)); } else { // Propagate template. if (_footer != null) { _footer._template = this._template; } var element = new BodyElement { Content = builder.ToString(), Attributes = attributes, Footer = _footer != null?_footer.ToString() : string.Empty }; return(_template.Body()(element)); } }
/// <summary> /// Starting point for creating a body with a custom template and a footer. /// </summary> /// <param name="template"></param> /// <param name="footer"></param> /// <returns></returns> public static MailBlockFluent CreateBody(MailBodyTemplate template, MailBlockFluent footer = null) { var instance = new MailBlockFluent(template, footer, isBlock: false); return(instance); }
public MailBlockFluent(MailBodyTemplate template, MailBlockFluent footer) { _template = template; _footer = footer; }
public MailBlockFluent(MailBodyTemplate template, MailBlockFluent footer, bool isBlock) { _template = template; _footer = footer; _isBlock = isBlock; }