drogonframework / drogonframework/drogon

How to better understand parameter binding rules

Open
#2,325 2 comments 1 reaction 0 assignees View on GitHub
Dominant language
C++
Stars
14.3k
Forks
1.4k
Avg merge
1d 13h
Merged PRs (30d)
14

Description

Is this a true limitation or I am just not understanding the usage?

Drogon's CSP Syntax Limitation

The <%view%> directive seems to be primarily for rendering subtemplates, but it doesn't automatically forward variables from the parent context.

Unlike some templating engines (e.g., Jinja2, Django), Drogon requires explicit parameter passing.

This
```
<%c++
if (!recommendedUsers.empty()) {
for (const auto& user : recommendedUsers) {
%>
<%view user_card_connected user=user %>
<%c++
}
} else {
%>

No recommended users found.


<%c++
}
%>
```

The user_card_connected.csp holds something like this `<%c++ $$ << user.username; %>`

Fails to work with the error

> keFiles/wahalao.dir/Unity/unity_6_cxx.cxx:22:
> /Applications/dev/cplusplus/wahalao/build/generated_views/module_network/user_card_connected.cc:23:36: error: use of undeclared identifier 'user'
> 23 | user_card_connected_tmp_stream << user.username;
> | ^
> 1 error generated.
> ninja: build stopped: subcommand failed.
> ✗ C++ build FAILED.
>

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.