Skip to content
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

Merged
merged 6 commits into from
Jan 24, 2018
Merged

Adding before and after tags #56

merged 6 commits into from
Jan 24, 2018

Conversation

wolves
Copy link

@wolves wolves commented Jan 23, 2018

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:

<%= f.SelectTag("Sample", {options: samples, after_tag: "<button>Button</button>"}) %>

Output:

<div class="form-group">
    <select id="Sample" name="Sample">
        ...samples
    </select>
    <button>Button</button>
</div>

Looking for criticisms/critiques/notes...

Christopher Stingl added 4 commits January 22, 2018 16:46
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 {
Copy link
Member

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 {
Copy link
Member

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 {
Copy link
Member

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 {
Copy link
Member

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) {
Copy link
Member

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"

@wolves wolves changed the title [WIP] Adding before and after tags Adding before and after tags Jan 24, 2018
@markbates
Copy link
Member

@paganotoni looks good to me. its yours to merge and release. :)

Copy link
Member

@paganotoni paganotoni left a 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!

@paganotoni paganotoni merged commit ca217ee into gobuffalo:master Jan 24, 2018
@wolves wolves deleted the adding_before_and_after_tags branch January 25, 2018 02:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants