{"id":13764031,"url":"https://github.com/dskinner/damsel","last_synced_at":"2025-08-16T16:09:50.158Z","repository":{"id":3176952,"uuid":"4208509","full_name":"dskinner/damsel","owner":"dskinner","description":"Package damsel provides html outlining via css-selectors and common template functionality.","archived":false,"fork":false,"pushed_at":"2016-04-07T02:54:55.000Z","size":75,"stargazers_count":24,"open_issues_count":1,"forks_count":6,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-08-14T04:06:27.633Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dskinner.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-05-02T23:06:48.000Z","updated_at":"2024-11-07T14:29:14.000Z","dependencies_parsed_at":"2022-08-19T06:21:36.057Z","dependency_job_id":null,"html_url":"https://github.com/dskinner/damsel","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dskinner/damsel","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dskinner%2Fdamsel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dskinner%2Fdamsel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dskinner%2Fdamsel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dskinner%2Fdamsel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dskinner","download_url":"https://codeload.github.com/dskinner/damsel/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dskinner%2Fdamsel/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270735313,"owners_count":24636340,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-16T02:00:11.002Z","response_time":91,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T15:01:06.496Z","updated_at":"2025-08-16T16:09:50.127Z","avatar_url":"https://github.com/dskinner.png","language":"Go","funding_links":[],"categories":["模板引擎","Template Engines","模板引擎`模版渲染和模版生成处理库`","Relational Databases","\u003cspan id=\"模板引擎-template-engines\"\u003e模板引擎 Template Engines\u003c/span\u003e"],"sub_categories":["交流","Advanced Console UIs","HTTP Clients","查询语","高級控制台界面","\u003cspan id=\"高级控制台用户界面-advanced-console-uis\"\u003e高级控制台用户界面 Advanced Console UIs\u003c/span\u003e","高级控制台界面"],"readme":"# Damsel [![GoDoc](https://godoc.org/dasa.cc/damsel?status.svg)](https://godoc.org/dasa.cc/damsel) [![Build Status](https://drone.dasa.cc/api/badges/dskinner/damsel/status.svg)](https://drone.dasa.cc/dskinner/damsel)\n\nMarkup language featuring html outlining via css-selectors, extensible via pkg html/template and others.\n\n## Library\n\nThis package expects to exist at `$GOPATH/src/dasa.cc/damsel` and can be installed with:\n\n```\ngo get dasa.cc/damsel\n```\n\n## Command Line\n\nA command line utility can be installed with:\n\n```\ngo get dasa.cc/damsel/cmd/damsel\n```\n\nView help with:\n\n```\ndamsel -h\n```\n\n## Documentation\n\nhttp://godoc.org/dasa.cc/damsel\n\nPackage damsel provides html outlining via css-selectors and common template functionality.\n\n### Tags\n\nTags are specified with %tag, #id, .class where #id and .class become a div\nif no %tag is specified. Multiple classes can be specified but only one #id\ntag should be specified for an element. It's also important that an #id tag\nis unique in the document as damsel facilitates overriding content of a\ndocument via an #id tag.\n\n\t%html %body\n\t  #content.border Hello, World\n\t  %div.one.two.three\n\n### Attributes\n\nAttributes can be inlined, line-breaked, or a combination of such. Provide\nquotes around the attribute value to escape brackets.\n\n\t%html %body\n\n\t  %div[a=1][b=2]\n\n\t  #foo\n\t    [a=\"1[1]\"]\n\t    [b=\"2[2]\"]\n\n\t  #bar[a=1][b=2]\n\t      [c=3][d=4]\n\n\t  %span[a][b] Attributes do not require values\n\n### Text and Whitespace\n\nWhitespace can be manipulated as described below, but it's worth pointing out that\nlarge amounts of content are simply not suitable for such document types (Damsel, Haml, etc).\n\n\t%p One\n\t  \\ Two\n\t  \\ Three\n\n\t%p    One Two Three\n\nBoth paragraphs will be rendered the same. Use of a backslash controls\nwhitespace, including inlined text.\n\n\t%p \\ One Two Three\n\nThis would insert a space before One.\n\nWhitespace can be preserved using `\n\n\t%p `this is some\n\ttext and all whitespace\n\t    is preserved as-is`\n\n### HTML Comments\n\nSupports commenting out blocks of code via html comments with optional\ntext and browser specfic IFs. This also includes DOCTYPE declarations.\n\n\t!DOCTYPE html\n\t%html %body\n\t  ! %ul\n\t    %li 1\n\t    %li 2\n\nThe use of ! as a block element, causing %ul to become inlined, will cause the\nentire block to become commented out. The ! could also be placed after the\nbody tag in this case. You can also nest items under a comment.\n\n\t%html %body\n\t  ! here's a comment though it's not required\n\t    %h1 Hello World\n\n\t  %div\n\t    ! this comment doesn't enclose any tags\n\t    %span Hello World\n\n\t  ![if IE] %p Internet Explorer\n\n### Actions\n\nThere is basic support for actions. An action is just another way of calling a function\nwhile also preserving indention of the inner content lines, making this suitable for\nparsing other indention based markup. Once an action has been processed, the lexer will parse\nthe result as though it was part of the original document.\n\nIn time, this package will facilitate custom functions. Currently\nincluded actions are js, css, include, and extends.\n\n\t%html %head\n\t  :css /css/\n\t    main.css\n\t    extra.css\n\nThis would generate the following document.\n\n\t%html %head\n\t  %link[type=text/css][rel=stylesheet][href=/css/main.css]\n\t  %link[type=text/css][rel=stylesheet][href=/css/extra.css]\n\n### Reusable Templates\n\nDamsel allows any element with an id specified to be overridden. Also required\nis at least one root node that will serve as the main document output.\nAdditional root nodes are checked against the first for overridable content.\n\n\t%html %body\n\t  #content\n\t    %p Hello\n\n\t#content OVERRIDE\n\nThe would produce the following output.\n\n\t\u003chtml\u003e\u003cbody\u003e\n\t  \u003cdiv id=\"content\"\u003eOVERRIDE\u003c/div\u003e\n\t\u003c/body\u003e\u003c/html\u003e\n\nThis functionality is also facilitated with the action extends.\n\n\t:extends overlay.dmsl\n\n\t#content OVERRIDE\n\nIf you wish to append child nodes instead of overriding the original content, specify a super attribute.\n\n\t:extends overlay.dmsl\n\n\t#content[super]\n\t  %p A second paragraph\n\nThe action include uses the whitespace preceding its declaration to insert\ncontent from a separate document into the current. For example, given the\nfollowing document:\n\n\t%ul\n\t  %li One\n\t  %li Two\n\nincluded in the following document:\n\n\t%html %body\n\t  #content\n\t    %h1 My Numbers\n\t    :include numbers.dmsl\n\nwould produce the following document:\n\n\t%html %body\n\t  #content\n\t    %h1 My Numbers\n\t    %ul\n\t      %li One\n\t      %li Two\n\n### Other Template Integration\n\nThis package should be ok for use with most text templating options. Helpers\nthat provide integration with html/template take the following steps.\n\n\t- Call dmsl/parse.ActionParse(b []byte)\n\t- Pass the result to package html/template and execute\n\t- Call dmsl/parse.DocParse(b []byte)\n\t- Display result\n\nCalling dmsl.NewHtmlTemplate will return an instance that parses actions and passes the result\nto html/template.Template. Call Execute(interface{}) to produce the final result. For example, given [10][10]int:\n\n\t%html %body\n\t  %table {range .}\n\t    %tr {range .}\n\t      %td {.}\n\t{end}{end}\n\nAt one-point the {end} was optional with deeper integration of html/template, but in practice this created\nconfusion and errors except for the most trivial of examples (above).\n\nHere's another example.\n\n\t%html %body\n\t  %table\n\t  {range .}\n\n\t    {if .}\n\n\t    %tr\n\t    {range .}\n\t      %td {.}\n\t    {end}\n\n\t    {else}\n\t    %tr %td None\n\t    {end}\n\n\t    %p some trailing text\n\t  {end}\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdskinner%2Fdamsel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdskinner%2Fdamsel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdskinner%2Fdamsel/lists"}