mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-23 05:51:39 +00:00
initial work
This commit is contained in:
parent
252325a7de
commit
bf65d8bfa8
7 changed files with 143 additions and 20 deletions
|
|
@ -1,5 +1,6 @@
|
|||
use std::{fmt, sync::Arc};
|
||||
|
||||
use rbx_dom_weak::{types::Ref, WeakDom};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// Legacy: ID attribute on target instances (kept for backwards compatibility)
|
||||
|
|
@ -11,6 +12,21 @@ pub const REF_POINTER_ATTRIBUTE_PREFIX: &str = "Rojo_Target_";
|
|||
/// No modification to the target instance is needed.
|
||||
pub const REF_PATH_ATTRIBUTE_PREFIX: &str = "Rojo_Ref_";
|
||||
|
||||
/// Compute the `Rojo_Ref_*` attribute name for a given property name.
|
||||
///
|
||||
/// Example: `ref_attribute_name("PrimaryPart")` returns `"Rojo_Ref_PrimaryPart"`.
|
||||
pub fn ref_attribute_name(prop_name: &str) -> String {
|
||||
format!("{REF_PATH_ATTRIBUTE_PREFIX}{prop_name}")
|
||||
}
|
||||
|
||||
/// Compute the path to a target instance for use in a `Rojo_Ref_*` attribute.
|
||||
/// Returns the slash-separated path from the root (root name excluded).
|
||||
///
|
||||
/// Example: an instance at `DataModel > Workspace > Part1` returns `"Workspace/Part1"`.
|
||||
pub fn ref_target_path(dom: &WeakDom, target_ref: Ref) -> String {
|
||||
dom.full_path_of(target_ref, "/")
|
||||
}
|
||||
|
||||
// TODO add an internment strategy for RojoRefs
|
||||
// Something like what rbx-dom does for SharedStrings probably works
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue