-
-
Notifications
You must be signed in to change notification settings - Fork 264
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
Add option to pass custom date and time formats #152
Add option to pass custom date and time formats #152
Conversation
@gazayas This looks good to me, and since the dependent PRs are already merged it seems like it should be good to go. Except for the fact that there's a merge conflict. If we can get the conflict sorted out I think we should merge this. |
@jagthedrummer I ended up removing the tests for the custom formats because Capybara wasn't picking up on the edited page. I originally was working with transformed_content = original_content.map do |line|
if line.match?(/attribute: :date_test/)
line.gsub(/ %>/, ", date_format: #{custom_date_format} %>")
elsif line.match?(/attribute: :date_time_test/)
line.gsub(/ %>/, ", date_format: #{custom_date_format}, time_format: #{custom_time_format} %>")
else
line
end
end After editing the file, running What I can do is write about the change in the docs, we just won't have tests for now. |
Now we just have 0 changes though, also because we added |
Just opened bullet-train-co/bullet_train-core#364, will go ahead and close this one. |
This gives developers the option to pass a custom format to
Date
andDateTime
partials.Context: https://discord.com/channels/836637622432170028/836637623048601633/973728513217675354
Given a model named
PartialTest
with aDate
attribute nameddate_test
, we can write the following:This gives developers the freedom to write their own formats if they want to.
Setup
I'm having a problem with the test because Capybara isn't picking up on the changes made when overwriting the file. I'm not quite sure how to handle this one, but I thought it would be better to push some tests rather than none.
Also, we need the
chronic
gem which is to be pulled in via this PR. Before that gets merged in, you can check the logic by replacing the appropriate Bullet Train packages in the Gemfile, along with simply adding Chronic: