Skip to content

fix: support inline style tags#118

Merged
davecoates merged 2 commits intomainfrom
fix/issue98-style-prop-handling
Mar 10, 2026
Merged

fix: support inline style tags#118
davecoates merged 2 commits intomainfrom
fix/issue98-style-prop-handling

Conversation

@davecoates
Copy link
Copy Markdown
Contributor

This supports both as a prop directly to {% component %}, and nested within on html tags

Resoles #98

@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 5, 2026

Codecov Report

❌ Patch coverage is 95.68966% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.47%. Comparing base (901b26a) to head (e489376).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...ges/ap-frontend/alliance_platform/frontend/util.py 95.37% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #118      +/-   ##
==========================================
+ Coverage   81.22%   81.47%   +0.25%     
==========================================
  Files          94       94              
  Lines        6646     6760     +114     
==========================================
+ Hits         5398     5508     +110     
- Misses       1248     1252       +4     
Flag Coverage Δ
ap-audit 78.46% <ø> (ø)
ap-codegen 79.69% <ø> (ø)
ap-core 68.38% <ø> (ø)
ap-frontend 79.61% <95.68%> (+0.86%) ⬆️
ap-ordered-model 94.46% <ø> (ø)
ap-pdf 81.69% <ø> (ø)
ap-server-choices 89.11% <ø> (ø)
ap-storage 89.52% <ø> (ø)
ap-ui 75.32% <ø> (ø)
django42 81.07% <95.68%> (+0.26%) ⬆️
django52 81.47% <95.68%> (+0.25%) ⬆️
py3.11 81.47% <95.68%> (+0.25%) ⬆️
py3.12 81.47% <95.68%> (+0.25%) ⬆️
py3.13 81.47% <95.68%> (+0.25%) ⬆️
py3.14 81.16% <95.68%> (+0.26%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.


def _split_css_declarations(style: str) -> list[str]:
declarations = []
current = []
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason not to implement current as an empty string that gets progressively modified rather than an empty list that gets converted later?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

technically more efficient (probably) as avoids string reallocations, but no particularly compelling reason - i think either way is clear

current.append(char)
continue
if char == ")" and paren_depth > 0:
paren_depth -= 1
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this have error handling for invalid CSS declarations? Parentheses depth less than 0 should probably throw a template syntax error.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, having looked at the tests it seems the standard is to ignore invalid declarations. I'm not sure what unexpected behaviour might arise from mismatched parentheses, though. Doesn't look like that case has a test, so one should probably be added.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to be explicit when encountering invalid parens and added test cases

def _split_css_declarations(style: str) -> list[str]:
declarations = []
current = []
quote: str | None = None
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: might be slightly easier to read if quote had exact literal typing.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah if it was typescript i would, but mypy is not so smart - can be done but you have to be much more explicit. e.g.

if char in {"'", '"'}:
    quote = char

will not pass anymore as doesn't refine the type, have to split it to

if char == "'":
   ...
elif char == '"':
   ...

This supports both as a prop directly to {% component %}, and
nested within on html tags

Resoles #98
@davecoates davecoates force-pushed the fix/issue98-style-prop-handling branch from 6c6e582 to e489376 Compare March 10, 2026 06:56
@davecoates davecoates merged commit 0a3b5df into main Mar 10, 2026
75 checks passed
@davecoates davecoates deleted the fix/issue98-style-prop-handling branch March 10, 2026 07:04
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.

2 participants