Skip to content

Support HTML in titles and descriptions #14

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

Merged
merged 2 commits into from
Jul 4, 2014
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/bootstrap-decorator.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions examples/bootstrap-example.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ <h3>Schema</h3>
},
"soul": {
"title": "Terms Of Service",
"description": "I agree to sell my undying soul",
"description": "I agree to sell my undying <a href='https://www.youtube.com/watch?v=dQw4w9WgXcQ'>soul</a>",
"type": "boolean",
"default": true,
},
Expand Down Expand Up @@ -192,7 +192,13 @@ <h3>Schema</h3>
]
},
{ key: "date", minDate: "2014-06-20" },
{ key: "radio", type: "radios" },
{ key: "radio",
type: "radios",
titleMap: {
"Transistor": "Transistor <br> Not the tube kind.",
"Tube": "Tube <br> The tube kind."
}
},
{ key: "radiobuttons", type: "radiobuttons" },
{
type: 'actions',
Expand Down
4 changes: 2 additions & 2 deletions src/directives/decorators/bootstrap/checkbox.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
ng-model="$$value$$"
schema-validate="form.schema"
ng-required="form.required">
{{form.title}}
<div ng-bind-html="form.title"></div>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Div is not a good choice here. Even if title would contain HTML code, a span would be more reasonable with title.

From json-schema definition: "A title will preferrably be short"

and about div in label:
http://stackoverflow.com/questions/18609554/is-div-inside-label-block-correct

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually had this discussion with @davidlgj. The reason we landed on div was due to us feeling it needed to be a block element, mainly due to stuff like line breaks or other things that semantically should not be in a inline element like a span. Thoughts?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say that a title should never contain block level elements. A description could, but description is never put in a label here what I can see.

Technically, you can't be sure of what the user puts in the title, but if they make the title block-level, they deserve broken html ;)

</label>

<span class="help-block" ng-show="form.description">{{form.description}}</span>
<span class="help-block" ng-show="form.description" ng-bind-html="form.description"></span>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

THIS might be a div, on the other hand.

</div>
4 changes: 2 additions & 2 deletions src/directives/decorators/bootstrap/checkboxes.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
sf-changed="form"
ng-model="checkboxValues[value]"
ng-change="$$value$$ = checkboxValuesToList(checkboxValues)" >
{{name}}
<div ng-bind-html="form.name"></div>
</label>

</div>
<span class="help-block" ng-show="form.description">{{form.description}}</span>
<span class="help-block" ng-show="form.description" ng-bind-html="form.description"></span>
</div>
2 changes: 1 addition & 1 deletion src/directives/decorators/bootstrap/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
<span ng-if="form.feedback !== false"
class="form-control-feedback"
ng-class="evalInScope(form.feedback) || {'glyphicon': true, 'glyphicon-ok': hasSuccess(), 'glyphicon-remove': hasError() }"></span>
<span class="help-block">{{ (hasError() && errorMessage(schemaError())) || form.description}}</span>
<span class="help-block" ng-show="form.description" ng-bind-html="(hasError() && errorMessage(schemaError())) || form.description"></span>
</div>
4 changes: 2 additions & 2 deletions src/directives/decorators/bootstrap/radio-buttons.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
style="display: none;"
ng-model="$$value$$"
ng-value="value">
{{name}}
<div ng-bind-html="name"></div>
</label>
</div>
<span class="help-block" ng-show="form.description">{{form.description}}</span>
<span class="help-block" ng-show="form.description" ng-bind-html="form.description"></span>
</div>
4 changes: 2 additions & 2 deletions src/directives/decorators/bootstrap/radios.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
sf-changed="form"
ng-model="$$value$$"
ng-value="value">
{{name}}
<div ng-bind-html="name"></div>
</label>
</div>
<span class="help-block" ng-show="form.description">{{form.description}}</span>
<span class="help-block" ng-show="form.description" ng-bind-html="form.description"></span>
</div>
4 changes: 2 additions & 2 deletions src/directives/decorators/bootstrap/readonly.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
<label ng-show="showTitle()">{{form.title}}</label>
<input ng-if="form.type !== 'textarea'" type="text" disabled class="form-control" value="{{$$value$$}}">
<textarea ng-if="form.type === 'textarea'" disabled class="form-control">{{$$value$$}}</textarea>
<span class="help-block" ng-show="form.description">{{form.description}} </span>
</div>
<span class="help-block" ng-show="form.description" ng-bind-html="form.description"></span>
</div>
2 changes: 1 addition & 1 deletion src/directives/decorators/bootstrap/select.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
ng-required="form.required"
ng-options="val as name for (val,name) in form.titleMap">
</select>
<span class="help-block">{{ (hasError() && errorMessage(schemaError())) || form.description}} </span>
<span class="help-block" ng-show="form.description" ng-bind-html="(hasError() && errorMessage(schemaError())) || form.description"></span>
</div>
2 changes: 1 addition & 1 deletion src/directives/decorators/bootstrap/textarea.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
<span ng-if="form.feedback !== false"
class="form-control-feedback"
ng-class="evalInScope(form.feedback) || { 'glyphicon': true, 'glyphicon-ok': hasSuccess(), 'glyphicon-remove': hasError() }"></span>
<span class="help-block">{{ (hasError() && errorMessage(schemaError())) || form.description}} </span>
<span class="help-block" ng-show="form.description" ng-bind-html="(hasError() && errorMessage(schemaError())) || form.description"></span>
</div>
Loading