-
-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding before and after tags #56
Adding before and after tags #56
Conversation
Refactor tag.String to call parseTagEmbed for handling the types for tag.Body, tag.BeforeTag, tag.AfterTag interfaces TODO: Dry up tag.String() further. Multiple calls to tag.AfterTag conditional based on body tags.Options and and voidTag conditional logic that surrounds closing the Tag.
tag.go
Outdated
func (t Tag) String() string { | ||
bb := &bytes.Buffer{} | ||
|
||
if len(t.BeforeTag) > 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need this if
statement. The range
will only run if there anything in the slice.
tag.go
Outdated
bb.WriteString("</") | ||
bb.WriteString(t.Name) | ||
bb.WriteString(">") | ||
|
||
if len(t.AfterTag) > 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need this if
statement. The range
will only run if there anything in the slice.
tag.go
Outdated
bb.WriteString("></") | ||
bb.WriteString(t.Name) | ||
bb.WriteString(">") | ||
|
||
if len(t.AfterTag) > 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need this if
statement. The range
will only run if there anything in the slice.
tag.go
Outdated
return bb.String() | ||
} | ||
bb.WriteString(" />") | ||
|
||
if len(t.AfterTag) > 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need this if
statement. The range
will only run if there anything in the slice.
tag.go
Outdated
@@ -43,8 +51,34 @@ type htmler interface { | |||
HTML() template.HTML | |||
} | |||
|
|||
func parseTagEmbed(b interface{}, bb *bytes.Buffer) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have this return a string
instead of taking in a bytes.Buffer
, it seems a little too "tied to implementation"
@paganotoni looks good to me. its yours to merge and release. :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me as well, thanks @wolves!
Adding an implementation of before/after_tag for the ability to specify a string or other tag within the
tags.Options{}
which will primarily help when using tags with bootstrap, as shown in the example.Example:
Output:
Looking for criticisms/critiques/notes...