Skip to content
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

Allow conditionnal blocks within template #8

Merged
merged 2 commits into from
Oct 5, 2012
Merged

Conversation

ccocchi
Copy link
Owner

@ccocchi ccocchi commented Oct 5, 2012

To replace if and unless within template we introduce the condition keyword. It takes a proc (that take the current object rendered) as argument and a block. The block is parsed at compile time.

The source compiled from the block will be called if the proc is evaluated as true at rendering time. Here's a use example

object :@user

attributes :name
condition(->(u) { u == current_user }) do
 attributes :secret
end

Conflicts:
	lib/rabl-rails.rb
	test/renderers/json_renderer_test.rb
ccocchi added a commit that referenced this pull request Oct 5, 2012
Allow conditionnal blocks within template
@ccocchi ccocchi merged commit 140a80e into master Oct 5, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant