Skip to content

Commit

Permalink
#168: Move Bolero.Html to a separate assembly with inlines
Browse files Browse the repository at this point in the history
  • Loading branch information
Tarmil committed Jul 23, 2020
1 parent aea0c10 commit a2d8252
Show file tree
Hide file tree
Showing 13 changed files with 2,391 additions and 2,352 deletions.
15 changes: 15 additions & 0 deletions Bolero.sln
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Bolero.Templating.Provider"
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Unit.Client", "tests\Unit.Client\Unit.Client.fsproj", "{61B550E1-6348-4A5E-BFB0-6A0220522EBF}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Bolero.Html", "src\Bolero.Html\Bolero.Html.fsproj", "{47381EA9-6744-4BE8-9C78-E3BD22EA3B3D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -167,6 +169,18 @@ Global
{61B550E1-6348-4A5E-BFB0-6A0220522EBF}.Release|x64.Build.0 = Release|Any CPU
{61B550E1-6348-4A5E-BFB0-6A0220522EBF}.Release|x86.ActiveCfg = Release|Any CPU
{61B550E1-6348-4A5E-BFB0-6A0220522EBF}.Release|x86.Build.0 = Release|Any CPU
{47381EA9-6744-4BE8-9C78-E3BD22EA3B3D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{47381EA9-6744-4BE8-9C78-E3BD22EA3B3D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{47381EA9-6744-4BE8-9C78-E3BD22EA3B3D}.Debug|x64.ActiveCfg = Debug|Any CPU
{47381EA9-6744-4BE8-9C78-E3BD22EA3B3D}.Debug|x64.Build.0 = Debug|Any CPU
{47381EA9-6744-4BE8-9C78-E3BD22EA3B3D}.Debug|x86.ActiveCfg = Debug|Any CPU
{47381EA9-6744-4BE8-9C78-E3BD22EA3B3D}.Debug|x86.Build.0 = Debug|Any CPU
{47381EA9-6744-4BE8-9C78-E3BD22EA3B3D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{47381EA9-6744-4BE8-9C78-E3BD22EA3B3D}.Release|Any CPU.Build.0 = Release|Any CPU
{47381EA9-6744-4BE8-9C78-E3BD22EA3B3D}.Release|x64.ActiveCfg = Release|Any CPU
{47381EA9-6744-4BE8-9C78-E3BD22EA3B3D}.Release|x64.Build.0 = Release|Any CPU
{47381EA9-6744-4BE8-9C78-E3BD22EA3B3D}.Release|x86.ActiveCfg = Release|Any CPU
{47381EA9-6744-4BE8-9C78-E3BD22EA3B3D}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -182,6 +196,7 @@ Global
{328CE686-3CB0-4AC7-9779-866ABE310DF6} = {8BE98B06-91C5-4948-B5AA-F80C67849031}
{770469C8-531A-4317-9BCE-DFF61E79B944} = {8BE98B06-91C5-4948-B5AA-F80C67849031}
{61B550E1-6348-4A5E-BFB0-6A0220522EBF} = {7EB0C3D3-0BD4-4D72-8ACF-A30B71F7C8E8}
{47381EA9-6744-4BE8-9C78-E3BD22EA3B3D} = {8BE98B06-91C5-4948-B5AA-F80C67849031}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {5493A436-6524-48E0-874D-CD70C1615AAF}
Expand Down
18 changes: 9 additions & 9 deletions build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,15 @@ let runTags filename apply =

Target.description "Generate HTML tags and attributes from CSV"
Target.create "tags" (fun _ ->
runTags "src/Bolero/Html.fs" (
runTags "src/Bolero.Html/Html.fs" (
replace (Tags.GetSample().Rows) "TAGS" (fun s tag ->
let esc = escapeDashes tag.Name
let ident = if tag.NeedsEscape then "``" + esc + "``" else esc
let childrenArg = if tag.CanHaveChildren then " (children: list<Node>)" else ""
let childrenVal = if tag.CanHaveChildren then "children" else "[]"
s.AppendLine(sprintf """/// Create an HTML `<%s>` element.""" tag.Name)
.AppendLine( """/// [category: HTML tag names]""")
.AppendLine(sprintf """let %s (attrs: list<Attr>)%s : Node =""" ident childrenArg)
.AppendLine(sprintf """let inline %s (attrs: list<Attr>)%s : Node =""" ident childrenArg)
.AppendLine(sprintf """ elt "%s" attrs %s""" tag.Name childrenVal)
.AppendLine()
)
Expand All @@ -117,27 +117,27 @@ Target.create "tags" (fun _ ->
elif attr.NeedsEscape then "``" + esc + "``"
else esc
s.AppendLine(sprintf """ /// Create an HTML `%s` attribute.""" attr.Name)
.AppendLine(sprintf """ let %s (v: obj) : Attr = "%s" => v""" ident attr.Name)
.AppendLine(sprintf """ let inline %s (v: obj) : Attr = "%s" => v""" ident attr.Name)
.AppendLine()
)
>> replace (Events.GetSample().Rows) "EVENTS" (fun s event ->
let esc = escapeDashes event.Name
s.AppendLine(sprintf """ /// Create a handler for HTML event `%s`.""" event.Name)
.AppendLine(sprintf """ let %s (callback: %sEventArgs -> unit) : Attr =""" esc event.Type)
.AppendLine(sprintf """ event "%s" callback""" esc)
.AppendLine(sprintf """ let inline %s (callback: %sEventArgs -> unit) : Attr =""" esc event.Type)
.AppendLine(sprintf """ attr.callback<%sEventArgs> ("on%s") callback""" event.Type esc)
.AppendLine()
)
>> replace (Events.GetSample().Rows) "ASYNCEVENTS" (fun s event ->
let esc = escapeDashes event.Name
s.AppendLine(sprintf """ /// Create an asynchronous handler for HTML event `%s`.""" event.Name)
.AppendLine(sprintf """ let %s (callback: %sEventArgs -> Async<unit>) : Attr =""" esc event.Type)
.AppendLine(sprintf """ event "%s" callback""" esc)
.AppendLine(sprintf """ let inline %s (callback: %sEventArgs -> Async<unit>) : Attr =""" esc event.Type)
.AppendLine(sprintf """ attr.async.callback<%sEventArgs> "on%s" callback""" event.Type esc)
)
>> replace (Events.GetSample().Rows) "TASKEVENTS" (fun s event ->
let esc = escapeDashes event.Name
s.AppendLine(sprintf """ /// Create an asynchronous handler for HTML event `%s`.""" event.Name)
.AppendLine(sprintf """ let %s (callback: %sEventArgs -> Task) : Attr =""" esc event.Type)
.AppendLine(sprintf """ event "%s" callback""" esc)
.AppendLine(sprintf """ let inline %s (callback: %sEventArgs -> Task) : Attr =""" esc event.Type)
.AppendLine(sprintf """ attr.task.callback<%sEventArgs> "on%s" callback""" event.Type esc)
)
)
runTags "src/Bolero.Templating.Provider/Parsing.fs" (
Expand Down
14 changes: 14 additions & 0 deletions src/Bolero.Html/Bolero.Html.fsproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<RootNamespace>Bolero</RootNamespace>
</PropertyGroup>
<ItemGroup>
<Compile Include="Html.fs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Bolero\Bolero.fsproj" />
</ItemGroup>
<Import Project="..\..\.paket\Paket.Restore.targets" />
</Project>
Loading

0 comments on commit a2d8252

Please sign in to comment.