8000 Mstch::object derived class can only contain methods with no parameters. · Issue #36 · no1msd/mstch · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content 8000
Mstch::object derived class can only contain methods with no parameters. #36
Open
@InsulinJunkie

Description

@InsulinJunkie

It would be a great improvement, in my opinion, if the mstch::object daughter class could accept one std::string argument as a lambda function would.

Here i created a silly example where i want only the Chris to be bold other names does not deserves such a good treatment. In the current state of the code base this code would not compile.
`class example: public mstch::object {
public:
example(): m_value(1) {
register_methods(this, {
{"count", &example::count},
{"names", &example::names},
{"boldify", &example::boldify}
});
}

mstch::node count() {
return m_value++;
}
mstch::node boldify(const std::string& input) {
return input == "Chris" ? " + input + " : input;
}

mstch::node names() {
return mstch::array{
std::string{"Chris"}, std::string{"Mark"}, std::string{"Scott"}};
}

private:
int m_value;
};

std::string view{"{{#names}}{{#boldify}}{count}}{{/boldify}}: {{.}}\n{{/names}}"};
const auto context = std::make_shared();

std::cout << mstch::render(view, context) << std::endl;`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0