Module slack_blocks::blox[][src]

This is supported on crate feature blox only.
Expand description

XML macro builder support

Blocks

blocks::Actions - <actions_block>

blocks::Header - <header_block> or <h1>

blocks::Block::Divider - <divider_block> or <hr>

blocks::Section - <section_block>

blocks::Input - <input_block>

blocks::Context - <context_block>

blocks::File - <file_block>

blocks::Image - <img_block>

Block Elements

elems::TextInput - <text_input>

elems::Image - <img>

elems::Button - <button>

elems::Checkboxes - <checkboxes>

elems::DatePicker - <date_picker>

elems::Overflow - <overflow>

elems::Radio - <radio_buttons>

elems::select - <select>

Composition Objects

compose::text - <text()>

compose::opt - <option>

compose::opt_group - <option_group>

compose::Confirm - <confirm>

Example

Using an example from Slack’s Documentation:

{
  "type": "section",
  "text": {
    "text": "*Sally* has requested you set the deadline for the Nano launch project",
    "type": "mrkdwn"
  },
  "accessory": {
    "type": "datepicker",
    "action_id": "datepicker123",
    "initial_date": "1990-04-28",
    "placeholder": {
      "type": "plain_text",
      "text": "Select a date"
    }
  }
}
use slack_blocks::blox::*;

let pick_date = blox! {
  <date_picker action_id="datepicker123"
               placeholder="Select a date"
               initial_date=(28, 4, 1990) />
};

let section = blox! {
  <section_block accessory=pick_date>
    <text kind=plain>"*Sally* has requested you set the deadline for the Nano launch project"</text>
  </section_block>
};

Re-exports

pub use elems::button::Style::Danger as btn_danger;
pub use elems::button::Style::Primary as btn_primary;
pub use elems::select::build::choose::multi;
pub use elems::select::build::choose::single;
pub use elems::select::build::data_source::conversations;
pub use elems::select::build::data_source::external;
pub use elems::select::build::data_source::public_channels;
pub use elems::select::build::data_source::static_;
pub use elems::select::build::data_source::users;
pub use text::build::kind::mrkdwn;
pub use text::build::kind::plain;

Macros

blox

Accepts an XML-like expression and expands it to builder method calls.

Structs

DividerBuilder

Dummy builder so blocks::Block::Divider can be built with XML macro

Traits

IntoChild

Identity trait to appease the mox macro

Functions

actions_block

blocks::Actions - <actions_block>

button

elems::Button - <button>

checkboxes

elems::Checkboxes - <checkboxes>

confirm

compose::Confirm - <confirm>

context_block

blocks::Context - <context_block>

date_picker

elems::DatePicker - <date_picker>

divider_block

blocks::Block::Divider - <divider_block /> or <hr />

file_block

blocks::File - <file_block>

h1

Alias for header_block

header_block

blocks::Header - <header_block> or <h1>

hr

Alias for divider_block

img

elems::Image - <img />

img_block

blocks::Image - <img_block>

input_block

blocks::Input - <input_block>

option

compose::opt - <option>

option_group

compose::opt_group - <option_group>

overflow

elems::Overflow - <overflow>

radio_buttons

elems::Radio - <radio_buttons>

section_block

blocks::Section - <section_block>

select

elems::select - <select>

text

compose::text - <text>

text_input

elems::TextInput - <text_input>