| 75 |
75 |
|
action: Option<Markup<'_>>,
|
| 76 |
76 |
|
opts: &Emit,
|
| 77 |
77 |
|
out: &mut String,
|
|
78 |
+ |
) {
|
|
79 |
+ |
emit_placeholder(state, message, action, opts, out, None);
|
|
80 |
+ |
}
|
|
81 |
+ |
|
|
82 |
+ |
/// A placeholder, saying where the way out landed.
|
|
83 |
+ |
///
|
|
84 |
+ |
/// Byte-identical to [`placeholder_html_into`], and where there is a way out it
|
|
85 |
+ |
/// sets `placed` to the offsets in `out` between which the whole
|
|
86 |
+ |
/// `placeholder-action` block was written -- the wrapper included, since the
|
|
87 |
+ |
/// wrapper is what goes with it. `None` stays `None` when there is no action.
|
|
88 |
+ |
///
|
|
89 |
+ |
/// Same reason as the other placed forms in this crate: a caller compiling this
|
|
90 |
+ |
/// markup into a template has to know which bytes the way out produced, and the
|
|
91 |
+ |
/// way out is a caller-supplied string that may appear elsewhere in the
|
|
92 |
+ |
/// document.
|
|
93 |
+ |
pub fn placeholder_html_placed(
|
|
94 |
+ |
state: Readiness,
|
|
95 |
+ |
message: &str,
|
|
96 |
+ |
action: Option<Markup<'_>>,
|
|
97 |
+ |
opts: &Emit,
|
|
98 |
+ |
out: &mut String,
|
|
99 |
+ |
placed: &mut Option<core::ops::Range<usize>>,
|
|
100 |
+ |
) {
|
|
101 |
+ |
emit_placeholder(state, message, action, opts, out, Some(placed));
|
|
102 |
+ |
}
|
|
103 |
+ |
|
|
104 |
+ |
fn emit_placeholder(
|
|
105 |
+ |
state: Readiness,
|
|
106 |
+ |
message: &str,
|
|
107 |
+ |
action: Option<Markup<'_>>,
|
|
108 |
+ |
opts: &Emit,
|
|
109 |
+ |
out: &mut String,
|
|
110 |
+ |
placed: Option<&mut Option<core::ops::Range<usize>>>,
|
| 78 |
111 |
|
) {
|
| 79 |
112 |
|
if state.shows_content() {
|
| 80 |
113 |
|
return;
|
| 103 |
136 |
|
escape_into(message, out);
|
| 104 |
137 |
|
out.push_str("</p>");
|
| 105 |
138 |
|
if let Some(Markup(markup)) = action {
|
|
139 |
+ |
let at = out.len();
|
| 106 |
140 |
|
out.push_str("<div class=\"");
|
| 107 |
141 |
|
push_class(out, "placeholder-action", opts);
|
| 108 |
142 |
|
out.push_str("\">");
|
| 109 |
143 |
|
out.push_str(markup);
|
| 110 |
144 |
|
out.push_str("</div>");
|
|
145 |
+ |
if let Some(placed) = placed {
|
|
146 |
+ |
*placed = Some(at..out.len());
|
|
147 |
+ |
}
|
| 111 |
148 |
|
}
|
| 112 |
149 |
|
out.push_str("</div>");
|
| 113 |
150 |
|
}
|